The Code:
$months = array("January", "February" .......); // Up to December
foreach ($months As $month) {
$date_ranges_from[] = date('F d, Y H:m:s', strtotime("$month 1 midnight"));
}
print_r($date_ranges_from);
The Undesired output:
// Notice that the minutes are auto-incremented
Array
(
[0] => January 01, 2015 00:01:00
[1] => February 01, 2015 00:02:00
[2] => March 01, 2015 00:03:00
[3] => April 01, 2015 00:04:00
[4] => May 01, 2015 00:05:00
[5] => June 01, 2015 00:06:00
[6] => July 01, 2015 00:07:00
[7] => August 01, 2015 00:08:00
[8] => September 01, 2015 00:09:00
[9] => October 01, 2015 00:10:00
[10] => November 01, 2015 00:11:00
[11] => December 01, 2015 00:12:00
)
The Desired output:
// The time should always be 00:00:00
Array
(
[0] => January 01, 2015 00:00:00
[1] => February 01, 2015 00:00:00
[2] => March 01, 2015 00:00:00
[3] => April 01, 2015 00:00:00
[4] => May 01, 2015 00:00:00
[5] => June 01, 2015 00:00:00
[6] => July 01, 2015 00:00:00
[7] => August 01, 2015 00:00:00
[8] => September 01, 2015 00:00:00
[9] => October 01, 2015 00:00:00
[10] => November 01, 2015 00:00:00
[11] => December 01, 2015 00:00:00
)
The problem: I don't know why the minutes gets also incremented when I statically put it as midnight. Any help would be appreciated thanks.