Jump to content

Simple Date Loop


chasethemetal

Recommended Posts

Hey all! I'm trying to loop a date count, how would I put this in a loop? $start = date('Y-m-d'); and $end = date('Y-m-d', strtotime('+30 days'));Then the output would be... 2011-12-10 2011-12-11 2011-12-12 and so forth all the way up to 30 days... I know how to count numbers up in loops, but when it comes to date's I'm getting very confused. Any references or examples would be much appreciated! Thanks!

Link to comment
Share on other sites

$date = mktime(0,0,0,1, 1, 2011); //set date to work to$start = date('d', $date ); //set start date from set date$end = date('t', $date ); // get total number of days in month for set month and year (including leap year)while ($start <= $end) { //loop through days of set month of set yearecho date('Y-m-d', mktime(0,0,0,date('m', $date ), $start, date('Y', $date ))).'<br />';$start++;}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...