Expected Input:
getDatesFromRange( '2010-10-01', '2010-10-05' );
Expected Output:
Array( '2010-10-01', '2010-10-02', '2010-10-03', '2010-10-04', '2010-10-05' )
Expected Input:
getDatesFromRange( '2010-10-01', '2010-10-05' );
Expected Output:
Array( '2010-10-01', '2010-10-02', '2010-10-03', '2010-10-04', '2010-10-05' )
Solution for PHP 5.2 with DateTime objects. But startDate MUST be before endDate.
Using:
$dates contain:
source: http://boonedocks.net/mike/archives/137-Creating-a-Date-Range-Array-with-PHP.html
You must add $end->modify('+1 day') to include last day of interval, for example the January will have a 31 days instead of 30 without using modify() method. This version of code will include the last day of the interval:
PHP doc link