Looping through dates in php

Looping through dates from a start date to an end date.

<?php
 $date = '2015-01-01';//start date
 $end_date = '2015-12-31';//end date
 $dates = array();
 while (strtotime($date) <= strtotime($end_date)) {
 	$dates[] = $date;
 	$date = date ("Y-m-d", strtotime("+1 day", strtotime($date)));
 }
 var_dump($dates);
 // foreach($dates as $d) {
 // 	echo $d."\n";
 // }

Search within Codexpedia

Custom Search

Search the entire web

Custom Search