3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dt = new DateTime('1/8/2019 12:00:00', new DateTimeZone('America/New_York')); $dt->sub('P7D'); var_dump($dt->format('c'));
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Fatal error: Uncaught TypeError: DateTime::sub(): Argument #1 ($interval) must be of type DateInterval, string given in /in/vUig9:4 Stack trace: #0 /in/vUig9(4): DateTime->sub('P7D') #1 {main} thrown in /in/vUig9 on line 4
Process exited with code 255.
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: DateTime::sub() expects parameter 1 to be DateInterval, string given in /in/vUig9 on line 4 string(25) "2019-01-08T12:00:00-05:00"

preferences:
197.6 ms | 402 KiB | 208 Q