3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $start = (new DateTime('2014-01-01'))->modify('first day of this month'); $end = (new DateTime('2015-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 CpEOo
Output for 5.4.0 - 5.6.30, hhvm-3.10.1 - 3.22.0, 7.0.0 - 7.2.0
Array ( [0] => January 2014 [1] => February 2014 [2] => March 2014 [3] => April 2014 [4] => May 2014 [5] => June 2014 [6] => July 2014 [7] => August 2014 [8] => September 2014 [9] => October 2014 [10] => November 2014 [11] => December 2014 [12] => January 2015 [13] => February 2015 )
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/smS3N on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_OBJECT_OPERATOR in /in/smS3N on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/smS3N on line 2
Process exited with code 255.