3v4l.org

run code in 300+ PHP versions simultaneously
<?php $lastDate = '01-11-2016'; $interval = 'P0Y0M1D'; $lastJob = new \Datetime(); $lastJob->setTimestamp($lastDate); echo ('Last Sent: '.$lastJob->format('Y/m/d')); echo " "; $interval = new DateInterval($interval); echo ('Interval: '.$interval->format('%y years, %m months, %d days')); echo " "; echo $lastJob->diff($currentJob); echo " "; echo $lastJob->add($interval);
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::setTimestamp(): Argument #1 ($timestamp) must be of type int, string given in /in/I0VTn:5 Stack trace: #0 /in/I0VTn(5): DateTime->setTimestamp('01-11-2016') #1 {main} thrown in /in/I0VTn on line 5
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Notice: A non well formed numeric value encountered in /in/I0VTn on line 5 Last Sent: 1970/01/01 Interval: 0 years, 0 months, 1 days Notice: Undefined variable: currentJob in /in/I0VTn on line 14 Warning: DateTime::diff() expects parameter 1 to be DateTimeInterface, null given in /in/I0VTn on line 14 Fatal error: Uncaught Error: Object of class DateTime could not be converted to string in /in/I0VTn:17 Stack trace: #0 {main} thrown in /in/I0VTn on line 17
Process exited with code 255.
Output for 7.3.32 - 7.3.33
Last Sent: 1970/01/01 Interval: 0 years, 0 months, 1 days Warning: DateTime::diff() expects parameter 1 to be DateTimeInterface, null given in /in/I0VTn on line 14 Recoverable fatal error: Object of class DateTime could not be converted to string in /in/I0VTn on line 17
Process exited with code 255.
Output for 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.31
Notice: A non well formed numeric value encountered in /in/I0VTn on line 5 Last Sent: 1970/01/01 Interval: 0 years, 0 months, 1 days Notice: Undefined variable: currentJob in /in/I0VTn on line 14 Warning: DateTime::diff() expects parameter 1 to be DateTimeInterface, null given in /in/I0VTn on line 14 Recoverable fatal error: Object of class DateTime could not be converted to string in /in/I0VTn on line 17
Process exited with code 255.
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20
Notice: A non well formed numeric value encountered in /in/I0VTn on line 5 Last Sent: 1970/01/01 Interval: 0 years, 0 months, 1 days Notice: Undefined variable: currentJob in /in/I0VTn on line 14 Warning: DateTime::diff() expects parameter 1 to be DateTimeInterface, null given in /in/I0VTn on line 14 Catchable fatal error: Object of class DateTime could not be converted to string in /in/I0VTn on line 17
Process exited with code 255.

preferences:
167.37 ms | 402 KiB | 183 Q