Here is the original snippet:
PHP:--------------------------------------------------------------------------------
Code: Select all
<?php
$months[date("m")] = date("t"); // this numeric-month = how many days in month
$months[date("m", mktime(0,0,0,date("m") + 1))] = date("t", mktime(0,0,0,date("m") + 1));
$months[date("m", mktime(0,0,0,date("m") + 2))] = date("t", mktime(0,0,0,date("m") + 2));
foreach($months as $key => $val) {
for($i=1;$i<$val;$i++) {
if(date("w", mktime(0,0,0,$key,$i)) == 1){
$mondays[] = mktime(0,0,0,$key, $i, date("y"));
}
}
}
foreach($mondays as $key => $val) {
print date("l M d, Y", $val)."<br>\n";
}
?>What it does is basically loops through and pulls all the mondays (day/month/year) for the current month and the following 2 months.
What I want to do is actually have it loop through and list the last 12 weeks, but I am having problems with the year (seeing it changes into last december)
Heres the output from the above:
Monday Feb 03, 2003
Monday Feb 10, 2003
Monday Feb 17, 2003
Monday Feb 24, 2003
Monday Mar 03, 2003
Monday Mar 10, 2003
Monday Mar 17, 2003
Monday Mar 24, 2003
Monday Apr 07, 2003
Monday Apr 14, 2003
Monday Apr 21, 2003
Monday Apr 28, 2003
Basically, What I want to do is list the day\date\year of the start of each week (always on a monday) for the last 12 weeks.
Hope you understand.
Any help would be appreciated.
Santos