Reputation: 13
I want to know how to print all the dates between range of dates given in PHP 5.2 I do not want to call function for this task.
Upvotes: 1
Views: 2220
Reputation: 1965
This should do the job.
<?php
$start = '2013/01/01'; //start date
$end = '2013/01/30'; //end date
$dates = array();
$start = $current = strtotime($start);
$end = strtotime($end);
while ($current <= $end) {
$dates[] = date('Y/m/d', $current);
$current = strtotime('+1 days', $current);
}
//now $dates hold an array of all the dates within that date range
print_r($dates);
?>
Upvotes: 4