3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class JhDateTime extends DateTime {} $date1 = new JhDateTime("10 September 2014"); $date2 = new JhDateTime("17 December 2014"); $period = new \DatePeriod( $date1 , new \DateInterval("P1M"), $date2 ); foreach($period as $date) { var_dump($date); }
based on bVZ8R
Output for 5.5.24 - 7.1.0
object(JhDateTime)#5 (3) { ["date"]=> string(26) "2014-09-10 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(JhDateTime)#6 (3) { ["date"]=> string(26) "2014-10-10 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(JhDateTime)#5 (3) { ["date"]=> string(26) "2014-11-10 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(JhDateTime)#6 (3) { ["date"]=> string(26) "2014-12-10 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.30 - 5.4.45
object(DateTime)#5 (3) { ["date"]=> string(26) "2014-09-10 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#6 (3) { ["date"]=> string(26) "2014-10-10 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#5 (3) { ["date"]=> string(26) "2014-11-10 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#6 (3) { ["date"]=> string(26) "2014-12-10 00:00:00.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.3.0 - 5.4.29
object(DateTime)#5 (3) { ["date"]=> string(19) "2014-09-10 00:00:00" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#6 (3) { ["date"]=> string(19) "2014-10-10 00:00:00" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#5 (3) { ["date"]=> string(19) "2014-11-10 00:00:00" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#6 (3) { ["date"]=> string(19) "2014-12-10 00:00:00" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.2.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/5poHF on line 11 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/5poHF on line 13 Fatal error: Class 'DatePeriod' not found in /in/5poHF on line 11
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/5poHF on line 11 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/5poHF on line 13 Fatal error: Class 'DateTime' not found in /in/5poHF on line 4
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/5poHF on line 11 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/5poHF on line 13 Fatal error: Class jhdatetime: Cannot inherit from undefined class datetime in /in/5poHF on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/5poHF on line 11 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/5poHF on line 13 Fatal error: Class jhdatetime: Cannot inherit from undefined class datetime in /in/5poHF on line 4