3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = new DateTime(); $b =new DateTime(); $interval = date_diff($a, $db); echo $interval->format('%S');
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
Warning: Undefined variable $db in /in/2WWE2 on line 7 Fatal error: Uncaught TypeError: date_diff(): Argument #2 ($targetObject) must be of type DateTimeInterface, null given in /in/2WWE2:7 Stack trace: #0 /in/2WWE2(7): date_diff(Object(DateTime), NULL) #1 {main} thrown in /in/2WWE2 on line 7
Process exited with code 255.
Output for 7.3.16 - 7.3.31, 7.4.4 - 7.4.33
Notice: Undefined variable: db in /in/2WWE2 on line 7 Warning: date_diff() expects parameter 2 to be DateTimeInterface, null given in /in/2WWE2 on line 7 Fatal error: Uncaught Error: Call to a member function format() on bool in /in/2WWE2:8 Stack trace: #0 {main} thrown in /in/2WWE2 on line 8
Process exited with code 255.
Output for 7.3.32 - 7.3.33
Warning: date_diff() expects parameter 2 to be DateTimeInterface, null given in /in/2WWE2 on line 7 Fatal error: Uncaught Error: Call to a member function format() on bool in /in/2WWE2:8 Stack trace: #0 {main} thrown in /in/2WWE2 on line 8
Process exited with code 255.
Output for 7.2.29 - 7.2.33
Notice: Undefined variable: db in /in/2WWE2 on line 7 Warning: date_diff() expects parameter 2 to be DateTimeInterface, null given in /in/2WWE2 on line 7 Fatal error: Uncaught Error: Call to a member function format() on boolean in /in/2WWE2:8 Stack trace: #0 {main} thrown in /in/2WWE2 on line 8
Process exited with code 255.

preferences:
108.4 ms | 1354 KiB | 4 Q