You are here

12 July 2012

Iterate through date or time range using PHP.

Source code viewer
  1. // date range
  2. $dates = array();
  3. $start_date = time();
  4. $end_date = strtotime('+100 days');
  5. $date_count = round(($end_date - $start_date) / 86400);
  6. for ($i = 0; $i < $date_count; ++$i) {
  7. $dates[] = date('Y.m.d', strtotime('+'.$i.' days', $start_date));
  8. }
Programming Language: PHP