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' )
To make Mostafa's answer complete, this is definietly the simplest and most efficient way to do it:
You can even change the default output date format if you add a third parameter when you call the function, otherwise it will use the default format that's been set as 'Y-m-d'.
I hope it helps :)
it will return array like below:
You could also take a look at the DatePeriod class:
Which should get you an array with DateTime objects.
To iterate
This is short, sweet, and should work in PHP4+.