3v4l.org

run code in 300+ PHP versions simultaneously
<?php $then = '2005-09-01 09:02:23'; $then = new DateTime($then); $now = '2005-09-01 09:02:23'; $sinceThen = $then->diff($now); //Combined echo $sinceThen;
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught TypeError: DateTime::diff(): Argument #1 ($targetObject) must be of type DateTimeInterface, string given in /in/9Fc6G:7 Stack trace: #0 /in/9Fc6G(7): DateTime->diff('2005-09-01 09:0...') #1 {main} thrown in /in/9Fc6G on line 7
Process exited with code 255.
Output for 5.5.8 - 5.5.38, 5.6.0 - 5.6.38, 7.0.0 - 7.0.33, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: DateTime::diff() expects parameter 1 to be DateTimeInterface, string given in /in/9Fc6G on line 7
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.7
Warning: DateTime::diff() expects parameter 1 to be DateTime, string given in /in/9Fc6G on line 7

preferences:
221.9 ms | 402 KiB | 339 Q