3v4l.org

run code in 300+ PHP versions simultaneously
<?php $current = date('Y-m-d'); $nextBusinessDay = date('Y-m-d', strtotime($current . '+ 3 Weekday')); $interval = date_diff($current, $nextBusinessDay); $diff = $interval->format('%R%a days'); var_dump($interval, $diff);
Output for 8.0.0 - 8.0.19, 8.1.0 - 8.1.6
Fatal error: Uncaught TypeError: date_diff(): Argument #1 ($baseObject) must be of type DateTimeInterface, string given in /in/dploU:5 Stack trace: #0 /in/dploU(5): date_diff('2016-01-29', '2016-02-03') #1 {main} thrown in /in/dploU on line 5
Process exited with code 255.
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.29
Warning: date_diff() expects parameter 1 to be DateTimeInterface, string given in /in/dploU on line 5 Fatal error: Uncaught Error: Call to a member function format() on bool in /in/dploU:6 Stack trace: #0 {main} thrown in /in/dploU on line 6
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33
Warning: date_diff() expects parameter 1 to be DateTimeInterface, string given in /in/dploU on line 5 Fatal error: Uncaught Error: Call to a member function format() on boolean in /in/dploU:6 Stack trace: #0 {main} thrown in /in/dploU on line 6
Process exited with code 255.
Output for 5.6.0 - 5.6.28
Warning: date_diff() expects parameter 1 to be DateTimeInterface, string given in /in/dploU on line 5 Fatal error: Call to a member function format() on boolean in /in/dploU on line 6
Process exited with code 255.
Output for 5.5.8 - 5.5.38
Warning: date_diff() expects parameter 1 to be DateTimeInterface, string given in /in/dploU on line 5 Fatal error: Call to a member function format() on a non-object in /in/dploU on line 6
Process exited with code 255.
Output for 5.5.0 - 5.5.7
Warning: date_diff() expects parameter 1 to be DateTime, string given in /in/dploU on line 5 Fatal error: Call to a member function format() on a non-object in /in/dploU on line 6
Process exited with code 255.

preferences:
51.84 ms | 416 KiB | 5 Q