3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $period = new \DatePeriod(new \DateTime('-7 days'), new \DateInterval('P1D'), new \DateTime()); var_dump(iterator_to_array($period));
Output for 7.1.0
array(7) { [0]=> object(DateTime)#3 (3) { ["date"]=> string(26) "2014-08-19 20:38:40.006554" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [1]=> object(DateTime)#4 (3) { ["date"]=> string(26) "2014-08-20 20:38:40.006554" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [2]=> object(DateTime)#5 (3) { ["date"]=> string(26) "2014-08-21 20:38:40.006554" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [3]=> object(DateTime)#6 (3) { ["date"]=> string(26) "2014-08-22 20:38:40.006554" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [4]=> object(DateTime)#7 (3) { ["date"]=> string(26) "2014-08-23 20:38:40.006554" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [5]=> object(DateTime)#8 (3) { ["date"]=> string(26) "2014-08-24 20:38:40.006554" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [6]=> object(DateTime)#9 (3) { ["date"]=> string(26) "2014-08-25 20:38:40.006554" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } }
Output for 7.0.14
array(7) { [0]=> object(DateTime)#3 (3) { ["date"]=> string(26) "2014-08-19 20:38:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [1]=> object(DateTime)#4 (3) { ["date"]=> string(26) "2014-08-20 20:38:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [2]=> object(DateTime)#5 (3) { ["date"]=> string(26) "2014-08-21 20:38:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [3]=> object(DateTime)#6 (3) { ["date"]=> string(26) "2014-08-22 20:38:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [4]=> object(DateTime)#7 (3) { ["date"]=> string(26) "2014-08-23 20:38:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [5]=> object(DateTime)#8 (3) { ["date"]=> string(26) "2014-08-24 20:38:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [6]=> object(DateTime)#9 (3) { ["date"]=> string(26) "2014-08-25 20:38:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } }
Output for 7.0.0 - 7.0.8
array(7) { [0]=> object(DateTime)#3 (3) { ["date"]=> string(26) "2013-12-28 16:53:03.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [1]=> object(DateTime)#4 (3) { ["date"]=> string(26) "2013-12-29 16:53:03.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [2]=> object(DateTime)#5 (3) { ["date"]=> string(26) "2013-12-30 16:53:03.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [3]=> object(DateTime)#6 (3) { ["date"]=> string(26) "2013-12-31 16:53:03.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [4]=> object(DateTime)#7 (3) { ["date"]=> string(26) "2014-01-01 16:53:03.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [5]=> object(DateTime)#8 (3) { ["date"]=> string(26) "2014-01-02 16:53:03.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [6]=> object(DateTime)#9 (3) { ["date"]=> string(26) "2014-01-03 16:53:03.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } }
Output for 5.6.28
array(7) { [0]=> object(DateTime)#2 (3) { ["date"]=> string(26) "2014-08-19 20:38:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [1]=> object(DateTime)#3 (3) { ["date"]=> string(26) "2014-08-20 20:38:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [2]=> object(DateTime)#4 (3) { ["date"]=> string(26) "2014-08-21 20:38:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [3]=> object(DateTime)#5 (3) { ["date"]=> string(26) "2014-08-22 20:38:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [4]=> object(DateTime)#6 (3) { ["date"]=> string(26) "2014-08-23 20:38:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [5]=> object(DateTime)#7 (3) { ["date"]=> string(26) "2014-08-24 20:38:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [6]=> object(DateTime)#8 (3) { ["date"]=> string(26) "2014-08-25 20:38:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } }
Output for 5.4.30 - 5.4.45, 5.5.14 - 5.6.23
array(7) { [0]=> object(DateTime)#2 (3) { ["date"]=> string(26) "2013-12-28 16:53:03.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [1]=> object(DateTime)#3 (3) { ["date"]=> string(26) "2013-12-29 16:53:03.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [2]=> object(DateTime)#4 (3) { ["date"]=> string(26) "2013-12-30 16:53:03.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [3]=> object(DateTime)#5 (3) { ["date"]=> string(26) "2013-12-31 16:53:03.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [4]=> object(DateTime)#6 (3) { ["date"]=> string(26) "2014-01-01 16:53:03.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [5]=> object(DateTime)#7 (3) { ["date"]=> string(26) "2014-01-02 16:53:03.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [6]=> object(DateTime)#8 (3) { ["date"]=> string(26) "2014-01-03 16:53:03.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } }
Output for 5.3.0 - 5.4.29, 5.5.0 - 5.5.13
array(7) { [0]=> object(DateTime)#2 (3) { ["date"]=> string(19) "2013-12-28 16:53:03" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [1]=> object(DateTime)#3 (3) { ["date"]=> string(19) "2013-12-29 16:53:03" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [2]=> object(DateTime)#4 (3) { ["date"]=> string(19) "2013-12-30 16:53:03" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [3]=> object(DateTime)#5 (3) { ["date"]=> string(19) "2013-12-31 16:53:03" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [4]=> object(DateTime)#6 (3) { ["date"]=> string(19) "2014-01-01 16:53:03" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [5]=> object(DateTime)#7 (3) { ["date"]=> string(19) "2014-01-02 16:53:03" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } [6]=> object(DateTime)#8 (3) { ["date"]=> string(19) "2014-01-03 16:53:03" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } }
Output for 5.0.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/lkXBs on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/lkXBs on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/lkXBs on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/lkXBs on line 2 Fatal error: Class 'DatePeriod' not found in /in/lkXBs on line 2
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/lkXBs on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/lkXBs on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/lkXBs on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/lkXBs on line 2 Fatal error: Cannot instantiate non-existent class: dateperiod in /in/lkXBs on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/lkXBs on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/lkXBs on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/lkXBs on line 2 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/lkXBs on line 2 Fatal error: Cannot instantiate non-existent class: dateperiod in /in/lkXBs on line 2