I have two dates and I would like to do a loop to display each day between thoses two dates.
Ex :
$begin=date("Y-m-d");
$end="2017-01-01";
I know how can I do with date in the past untill today, but I don't konw from today untill a date in the past. An idea ?
My script :
$today=date("Y-m-d");
$begin = new DateTime($today);
$end = new DateTime('2017-01-01');
$begin = $begin->modify( '-1 day' );
$interval = new DateInterval('P1D');
$period = new DatePeriod($begin, $interval, $end);
foreach ($period as $dt)
{
$datedisplay=$dt->format("Ymd" );
echo ''.$datedisplay.'<BR>';
}
Thank you !