3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $years = 20; $dob = new \DateTime(); $dob->add(\DateInterval::createFromDateString($years . ' years ago')); var_dump($dob);
based on 5RVL2
Output for 7.1.0
object(DateTime)#1 (3) { ["date"]=> string(26) "1994-10-03 14:09:57.003860" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.28, 7.0.14
object(DateTime)#1 (3) { ["date"]=> string(26) "1994-10-03 14:09:57.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.0.6
object(DateTime)#1 (3) { ["date"]=> string(26) "1996-05-03 18:29:54.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.0.5
object(DateTime)#1 (3) { ["date"]=> string(26) "1996-04-03 06:55:07.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.0.4
object(DateTime)#1 (3) { ["date"]=> string(26) "1996-03-10 18:42:01.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.0.3
object(DateTime)#1 (3) { ["date"]=> string(26) "1996-03-18 19:50:37.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.0.2
object(DateTime)#1 (3) { ["date"]=> string(26) "1996-03-23 01:58:02.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.0.1
object(DateTime)#1 (3) { ["date"]=> string(26) "1996-03-24 05:37:25.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.0.0
object(DateTime)#1 (3) { ["date"]=> string(26) "1996-03-27 07:33:32.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for hhvm-3.12.0
object(DateTime)#1 (3) { ["date"]=> string(26) "1996-03-13 10:14:21.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for hhvm-3.10.0
object(DateTime)#1 (3) { ["date"]=> string(26) "1996-03-31 01:49:47.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.21
object(DateTime)#1 (3) { ["date"]=> string(26) "1996-05-02 13:39:15.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.20
object(DateTime)#1 (3) { ["date"]=> string(26) "1996-04-10 05:54:25.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.19
object(DateTime)#1 (3) { ["date"]=> string(26) "1996-03-08 02:53:26.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.18
object(DateTime)#1 (3) { ["date"]=> string(26) "1996-03-15 11:36:45.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.17
object(DateTime)#1 (3) { ["date"]=> string(26) "1996-03-19 23:16:18.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.16
object(DateTime)#1 (3) { ["date"]=> string(26) "1996-03-28 08:20:52.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.15
object(DateTime)#1 (3) { ["date"]=> string(26) "1996-03-29 09:11:32.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.14
object(DateTime)#1 (3) { ["date"]=> string(26) "1996-04-02 11:02:42.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.13
object(DateTime)#1 (3) { ["date"]=> string(26) "1996-04-15 15:26:57.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.12
object(DateTime)#1 (3) { ["date"]=> string(26) "1996-04-20 05:56:04.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.11
object(DateTime)#1 (3) { ["date"]=> string(26) "1996-04-24 12:18:42.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.10
object(DateTime)#1 (3) { ["date"]=> string(26) "1996-04-25 14:21:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.9
object(DateTime)#1 (3) { ["date"]=> string(26) "1996-04-27 19:31:37.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.6.8
object(DateTime)#1 (3) { ["date"]=> string(26) "1996-04-30 04:23:47.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.35
object(DateTime)#1 (3) { ["date"]=> string(26) "1996-05-22 20:52:39.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.34
object(DateTime)#1 (3) { ["date"]=> string(26) "1996-04-11 08:06:23.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.33
object(DateTime)#1 (3) { ["date"]=> string(26) "1996-03-09 05:36:44.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.32
object(DateTime)#1 (3) { ["date"]=> string(26) "1996-03-17 15:32:13.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.31
object(DateTime)#1 (3) { ["date"]=> string(26) "1996-03-21 02:18:20.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.30
object(DateTime)#1 (3) { ["date"]=> string(26) "1996-04-01 11:05:18.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.29
object(DateTime)#1 (3) { ["date"]=> string(26) "1996-04-17 05:50:07.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.28
object(DateTime)#1 (3) { ["date"]=> string(26) "1996-04-21 09:09:59.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.27
object(DateTime)#1 (3) { ["date"]=> string(26) "1996-04-22 10:56:25.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.26
object(DateTime)#1 (3) { ["date"]=> string(26) "1996-04-26 17:04:25.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.25
object(DateTime)#1 (3) { ["date"]=> string(26) "1996-04-28 23:56:49.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.24
object(DateTime)#1 (3) { ["date"]=> string(26) "1996-05-24 06:29:23.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.45
object(DateTime)#1 (3) { ["date"]=> string(26) "1995-11-20 08:31:33.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.44
object(DateTime)#1 (3) { ["date"]=> string(26) "1995-11-20 08:31:34.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.43
object(DateTime)#1 (3) { ["date"]=> string(26) "1995-11-20 08:31:35.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.41 - 5.4.42
object(DateTime)#1 (3) { ["date"]=> string(26) "1995-11-20 08:31:36.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.39 - 5.4.40
object(DateTime)#1 (3) { ["date"]=> string(26) "1995-11-20 08:31:37.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.36 - 5.4.38
object(DateTime)#1 (3) { ["date"]=> string(26) "1995-11-20 08:31:38.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.34 - 5.4.35
object(DateTime)#1 (3) { ["date"]=> string(26) "1995-11-20 08:31:39.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.31 - 5.4.32
object(DateTime)#1 (3) { ["date"]=> string(26) "1995-11-20 08:31:40.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.30
object(DateTime)#1 (3) { ["date"]=> string(26) "1995-11-20 08:31:41.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.28 - 5.4.29
object(DateTime)#1 (3) { ["date"]=> string(19) "1995-11-20 08:31:41" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.25 - 5.4.27
object(DateTime)#1 (3) { ["date"]=> string(19) "1995-11-20 08:31:42" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.3.28, 5.4.22 - 5.4.24
object(DateTime)#1 (3) { ["date"]=> string(19) "1995-11-20 08:31:43" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.4.19 - 5.4.21
object(DateTime)#1 (3) { ["date"]=> string(19) "1995-11-20 08:31:44" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.3.26 - 5.3.27, 5.4.16 - 5.4.18
object(DateTime)#1 (3) { ["date"]=> string(19) "1995-11-20 08:31:45" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.3.23 - 5.3.25, 5.4.13 - 5.4.15
object(DateTime)#1 (3) { ["date"]=> string(19) "1995-11-20 08:31:46" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.3.20 - 5.3.22, 5.4.9 - 5.4.12
object(DateTime)#1 (3) { ["date"]=> string(19) "1995-11-20 08:31:47" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.3.16 - 5.3.19, 5.4.6 - 5.4.8
object(DateTime)#1 (3) { ["date"]=> string(19) "1995-11-20 08:31:48" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.3.12 - 5.3.15, 5.4.3 - 5.4.5
object(DateTime)#1 (3) { ["date"]=> string(19) "1995-11-20 08:31:49" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.3.8 - 5.3.11, 5.4.0 - 5.4.2
object(DateTime)#1 (3) { ["date"]=> string(19) "1995-11-20 08:31:50" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.3.29
object(DateTime)#1 (3) { ["date"]=> string(19) "1995-11-20 08:31:40" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.3.4 - 5.3.7
object(DateTime)#1 (3) { ["date"]=> string(19) "1995-11-20 08:31:51" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.3.0 - 5.3.3
object(DateTime)#1 (3) { ["date"]=> string(19) "1995-11-20 08:31:52" ["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/gqQlH on line 3 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/gqQlH on line 4 Fatal error: Call to undefined method DateTime::add() in /in/gqQlH on line 4
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/gqQlH on line 3 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/gqQlH on line 4 Fatal error: Class 'DateTime' not found in /in/gqQlH on line 3
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/gqQlH on line 3 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/gqQlH on line 4 Fatal error: Cannot instantiate non-existent class: datetime in /in/gqQlH on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/gqQlH on line 3 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/gqQlH on line 4 Fatal error: Cannot instantiate non-existent class: datetime in /in/gqQlH on line 3