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.6
Fatal error: Uncaught DateMalformedIntervalStringException: Unknown or bad format (P1D) at position 1 (1): Unexpected character in /in/PdQ0O:4 Stack trace: #0 /in/PdQ0O(4): DateInterval::createFromDateString('P1D') #1 {main} thrown in /in/PdQ0O on line 4
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/PdQ0O on line 4 Fatal error: Uncaught TypeError: DateTime::add(): Argument #1 ($interval) must be of type DateInterval, bool given in /in/PdQ0O:5 Stack trace: #0 /in/PdQ0O(5): DateTime->add(false) #1 {main} thrown in /in/PdQ0O on line 5
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/PdQ0O on line 4 Warning: DateTime::add() expects parameter 1 to be DateInterval, bool given in /in/PdQ0O on line 5 bool(false)
Output for 7.3.3
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:47:38.000179" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.23, 7.3.2
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:47:38.000120" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.17, 7.3.1
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:47:38.000124" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.4, 7.3.0
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:47:38.000112" ["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/PdQ0O on line 4 Warning: DateTime::add() expects parameter 1 to be DateInterval, boolean given in /in/PdQ0O on line 5 bool(false)
Output for 7.2.16
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:47:38.000183" ["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:47:38.000128" ["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:47:38.000103" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.2.13
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:47:38.000163" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.5, 7.2.11 - 7.2.12
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:47:38.000111" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.2.10
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:47:38.000108" ["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:47:38.000186" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.30, 7.2.8
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:47:38.000151" ["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:47:38.000138" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.12, 7.1.21, 7.2.6
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:47:38.000150" ["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:47:38.000106" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.19, 7.2.4
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:47:38.000157" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.2.3
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:47:38.031857" ["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:47:38.000095" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.2.1
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:47:38.000113" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.2.0
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:47:38.000134" ["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:47:38.000162" ["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:47:38.000129" ["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:47:38.000107" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.0, 7.1.29
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:47:38.000110" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.14, 7.1.28
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:47:38.000131" ["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:47:38.000140" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.26
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:47:38.000145" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.25
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:47:38.000102" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.24
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:47:38.000123" ["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:47:38.000190" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.15, 7.1.20
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:47:38.000104" ["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:47:38.000109" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.16
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:47:38.000156" ["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:47:38.000093" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.11
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:47:38.000160" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.10
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:47:39.000184" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.9
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:47:38.000225" ["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:47:38.000155" ["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:47:38.000189" ["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:47:38.000122" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.14 - 5.5.18, 5.5.20 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.3
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:47:38.000000" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.2
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:47:38.000114" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 7.1.1
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:47:38.000158" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }
Output for 5.5.19
object(DateTime)#1 (3) { ["date"]=> string(26) "2015-12-16 17:47:39.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:47:38" ["timezone_type"]=> int(3) ["timezone"]=> string(16) "Europe/Amsterdam" }

preferences:
302.17 ms | 402 KiB | 330 Q