Page 1 of 1

Adding seven days to date

Posted: Wed Oct 05, 2005 9:24 am
by Crew
Hi

I want to list all the mondays in the year, I can find the 1st using

Code: Select all

$date = date('Y-m-d',strtotime('this monday',mktime(0,0,0,1,1,2005)));
But how do I add 7 days to loop through this in Y-m-d format for the next year? Results will be displayed in a dropdown.

Posted: Wed Oct 05, 2005 9:32 am
by feyd
store the results of the strtotime()..something like this

Code: Select all

$start = strtotime('this monday',mktime(0,0,0,1,1,2005));
for($time = $start;date('Y',$time) == 2005; $time = strtotime('+7 day',$time)) {
  echo date('Y-m-d',$time)."\n";
}