3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $days = 7; $date1 = (new \DateTime())->add(new \DateInterval('P'.($days -1).'D')); $date2 = (new \DateTime())->modify('+'.$days.' day'); var_dump($date1, $date2);
Output for 7.1.0
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-03-06 17:40:22.003566" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2014-03-07 17:40:22.003577" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.0.12 - 7.0.14
object(DateTime)#1 (3) { ["date"]=> string(26) "2014-03-06 17:40:22.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2014-03-07 17:40:22.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.0.6
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-09 07:21:24.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-05-10 07:21:24.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.0.5
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-08 20:20:45.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-04-09 20:20:45.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.33, 5.6.18 - 5.6.19, hhvm-3.12.0, 7.0.4
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-18 00:50:45.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-19 00:50:45.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.31 - 5.5.32, 5.6.17, 7.0.1 - 7.0.3
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-18 00:50:46.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-19 00:50:46.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.30, 5.6.15 - 5.6.16, hhvm-3.10.0, 7.0.0
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-18 00:50:47.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-19 00:50:47.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.21
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-08 02:39:10.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-05-09 02:39:10.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.20
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-15 16:47:31.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-04-16 16:47:31.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.45, 5.5.29, 5.6.13 - 5.6.14
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-18 00:50:48.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-19 00:50:48.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.44, 5.5.27 - 5.5.28, 5.6.11 - 5.6.12
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-18 00:50:49.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-19 00:50:49.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.41 - 5.4.43, 5.5.25 - 5.5.26, 5.6.9 - 5.6.10
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-18 00:50:50.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-19 00:50:50.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.40, 5.5.24, 5.6.7 - 5.6.8
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-18 00:50:51.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-19 00:50:51.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.37 - 5.4.39, 5.5.21 - 5.5.23, 5.6.6
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-18 00:50:52.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-19 00:50:52.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.35 - 5.4.36, 5.5.20, 5.6.3 - 5.6.5
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-18 00:50:53.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-19 00:50:53.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.34, 5.5.16 - 5.5.19, 5.6.0 - 5.6.2
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-18 00:50:54.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-19 00:50:54.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.35
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-05-28 06:16:30.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-05-29 06:16:30.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.34
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-04-16 21:35:08.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-04-17 21:35:08.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.30 - 5.4.32, 5.5.14 - 5.5.15
object(DateTime)#1 (3) { ["date"]=> string(26) "2016-03-18 00:50:55.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(26) "2016-03-19 00:50:55.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.26 - 5.4.29, 5.5.11 - 5.5.13
object(DateTime)#1 (3) { ["date"]=> string(19) "2016-03-18 00:50:56" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(19) "2016-03-19 00:50:56" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.23 - 5.4.25, 5.5.8 - 5.5.10
object(DateTime)#1 (3) { ["date"]=> string(19) "2016-03-18 00:50:57" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(19) "2016-03-19 00:50:57" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.20 - 5.4.22, 5.5.5 - 5.5.7
object(DateTime)#1 (3) { ["date"]=> string(19) "2016-03-18 00:50:58" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(19) "2016-03-19 00:50:58" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.18 - 5.4.19, 5.5.1 - 5.5.4
object(DateTime)#1 (3) { ["date"]=> string(19) "2016-03-18 00:50:59" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(19) "2016-03-19 00:50:59" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.15 - 5.4.17, 5.5.0
object(DateTime)#1 (3) { ["date"]=> string(19) "2016-03-18 00:51:00" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(19) "2016-03-19 00:51:00" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.12 - 5.4.14
object(DateTime)#1 (3) { ["date"]=> string(19) "2016-03-18 00:51:01" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(19) "2016-03-19 00:51:01" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.8 - 5.4.11
object(DateTime)#1 (3) { ["date"]=> string(19) "2016-03-18 00:51:02" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(19) "2016-03-19 00:51:02" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.3 - 5.4.7
object(DateTime)#1 (3) { ["date"]=> string(19) "2016-03-18 00:51:03" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(19) "2016-03-19 00:51:03" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.0 - 5.4.2
object(DateTime)#1 (3) { ["date"]=> string(19) "2016-03-18 00:51:04" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" } object(DateTime)#2 (3) { ["date"]=> string(19) "2016-03-19 00:51:04" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.3.0 - 5.3.29
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/IX7aj on line 3
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/IX7aj on line 3 Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/IX7aj on line 3
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
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/IX7aj on line 3 Parse error: parse error, unexpected T_OBJECT_OPERATOR in /in/IX7aj on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/IX7aj on line 3 Parse error: parse error in /in/IX7aj on line 3
Process exited with code 255.