3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dt1 = new DateTime(); $ti = DateInterval::createFromDateString('P1D'); $dt2 = $dt1->add($ti); var_dump($dt2);
Output for 8.3.0 - 8.3.4, 8.3.6
Fatal error: Uncaught DateMalformedIntervalStringException: Unknown or bad format (P1D) at position 1 (1): Unexpected character in /in/i3m4r:5 Stack trace: #0 /in/i3m4r(5): DateInterval::createFromDateString('P1D') #1 {main} thrown in /in/i3m4r on line 5
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Fatal error: Uncaught DateMalformedIntervalStringException: Unknown or bad format (P1D) at position 1 (1): Unexpected character in /in/i3m4r:5 Stack trace: #0 /in/i3m4r(5): DateInterval::createFromDateString('P1D') #1 {main} thrown in /in/i3m4r on line 5
Process exited with code 255.
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18
Warning: DateInterval::createFromDateString(): Unknown or bad format (P1D) at position 1 (1): Unexpected character in /in/i3m4r on line 5 Fatal error: Uncaught TypeError: DateTime::add(): Argument #1 ($interval) must be of type DateInterval, bool given in /in/i3m4r:6 Stack trace: #0 /in/i3m4r(6): DateTime->add(false) #1 {main} thrown in /in/i3m4r on line 6
Process exited with code 255.
Output for 7.3.4 - 7.3.33, 7.4.0 - 7.4.33
Warning: DateInterval::createFromDateString(): Unknown or bad format (P1D) at position 1 (1): Unexpected character in /in/i3m4r on line 5 Warning: DateTime::add() expects parameter 1 to be DateInterval, bool given in /in/i3m4r on line 6 bool(false)
Output for 7.3.3
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000227" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.2.3, 7.3.2
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000153" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.3.1
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000110" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.3.0
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000142" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.2.17 - 7.2.33
Warning: DateInterval::createFromDateString(): Unknown or bad format (P1D) at position 1 (1): Unexpected character in /in/i3m4r on line 5 Warning: DateTime::add() expects parameter 1 to be DateInterval, boolean given in /in/i3m4r on line 6 bool(false)
Output for 7.2.16
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000210" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.2.15
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000111" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.2.14
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000096" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.29, 7.2.10, 7.2.13
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000097" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.2.12
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000092" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.2.11
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000125" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.2.9
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000122" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.4, 7.2.8
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000098" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.2.7
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000112" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.2.6
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000101" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.2.5
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000151" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.28, 7.2.4
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000139" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.2.2
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000130" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.9 - 7.1.10, 7.2.1
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000105" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.24, 7.2.0
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000140" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.33
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000184" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.32
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000164" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.31
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000094" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.30
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000113" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.27
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000177" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.11, 7.1.26
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000132" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.1, 7.1.25
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000108" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.23
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000093" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.22
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000173" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.21
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000178" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.20
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000155" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.19
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000181" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.18
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000131" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.17
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000120" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.2, 7.1.16
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000138" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.15
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000128" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.14
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000172" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.13
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000100" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.12
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000116" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.8
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000104" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.7
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000190" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.6
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000099" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.5
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000135" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.14 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.13, 7.0.15 - 7.0.33, 7.1.3
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.0
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:29.000102" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.0.14
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:46:30.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.0 - 5.5.13
object(DateTime)#1 (3) { ["date"]=> string(19) "2015-12-16 17:46:29" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }

preferences:
258.07 ms | 402 KiB | 330 Q