I have two dates of the form:
Start Date: 2015-01-25 13:45:01
End Date: 2015-01-28 02:58:01
Now I need to find the day between these two in the following form:
2015-01-25
2015-01-26
2015-01-27
2015-01-28
How can I do this in PHP?
I have two dates of the form:
Start Date: 2015-01-25 13:45:01
End Date: 2015-01-28 02:58:01
Now I need to find the day between these two in the following form:
2015-01-25
2015-01-26
2015-01-27
2015-01-28
How can I do this in PHP?
This should work for you:
(Here i just simply used DatePeriod)
<?php
$start = new DateTime("2015-01-25 13:45:01 ");
$end = new DateTime("2015-01-28 02:58:01");
$end = $end->modify("+1 day");
$interval = new DateInterval('P1D');
$dateRange = new DatePeriod($start, $interval ,$end);
foreach($dateRange as $date)
echo $date->format("Y-m-d") . "<br />";
?>
Output:
2015-01-25
2015-01-26
2015-01-27
2015-01-28