Try this:
$rpt_day='2007-01-01';
list($y,$m,$d) = explode('-', $rpt_day);
$ts = mktime(0,0,0,(int)$m, (int)$d, $y);
$lowEnd=date('w',$ts);
Main Topics
Browse All TopicsI found this nifty little piece of code on phpfreaks that will generate the dates for the week of the current day starting with Sunday:
$lowEnd=date('w');
$lowEnd=-$lowEnd;
$highEnd=$lowEnd + 6;
$weekday=0;
for ($i=$lowEnd; $i<=$highEnd; $i++)
{
$WeekDate[$weekday]=date('
$weekday++;
}
echo '<tr>';
for($i=0;$i<=6;$i++)
{
echo '<th>'.$WeekDate[$i].'</th
}
echo '</tr>';
The problem is generating the week for another day. If I use this line:
$rpt_day='2007-01-01';
$lowEnd=date('w',strtotime
The dates generated will not be the correct ones. I'm planning on adding arrows so the user can go to the previous or next week. Can someone give me a little hand on this? Thanks!
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: CraigHarrisPosted on 2007-01-27 at 16:15:17ID: 18412263
Your problem is the line: d-M-y',mkt ime(0, 0, 0, date("m") , date("d")+$i, date("Y")));
d-M-y', mktime(0, 0, 0, date("m", $CalcDate) , date("d", $CalcDate)+$i, date("Y", $CalcDate)));
d-M-y', StrToTime("+{$i} days", $CalcDate));
$WeekDate[$weekday]=date('
You will have to pass an appropriate timestamp to each Date() call else they will default to the time that the php script is run, not the week you want dates for
e.g.
$CalcDate = StrToTime($rpt_date);
//...
$owEnd=date('w', $CalcDate);
//...
$WeekDate[$weekday]=date('
// However, that last line is the same as doing:
$WeekDate[$weekday]=date('
// which is nicer IMO