3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $start = (new DateTime('2017-01-01'))->modify('first day of this month'); $end = (new DateTime('2018-03-04'))->modify('first day of this month'); $interval = DateInterval::createFromDateString('1 month'); $period = new DatePeriod($start, $interval, $end); $months = array(); foreach ($period as $dt) { $months[] = $dt->format("F Y"); } print_r($months);
based on smS3N
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.2.0
Array ( [0] => January 2017 [1] => February 2017 [2] => March 2017 [3] => April 2017 [4] => May 2017 [5] => June 2017 [6] => July 2017 [7] => August 2017 [8] => September 2017 [9] => October 2017 [10] => November 2017 [11] => December 2017 [12] => January 2018 [13] => February 2018 )