3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $now = new DateTimeImmutable; $departure = $now->modify('+42 hours'); echo $now->format('Y-m-d H:i:s') . PHP_EOL; echo $departure->format('Y-m-d H:i:s') . PHP_EOL; echo $now->diff($departure)->format('%h') . PHP_EOL;
based on F86la
Output for 5.5.8 - 7.3.1
2016-01-06 12:45:06 2016-01-08 06:45:06 18
Output for 5.5.0 - 5.5.7
2016-01-06 12:45:06 2016-01-08 06:45:06 Fatal error: DateTime::diff() must be derived from DateTimeImmutable::diff in Unknown on line 0
Process exited with code 255.
Output for 5.3.21 - 5.4.45
Fatal error: Class 'DateTimeImmutable' not found in /in/lDkQl on line 2
Process exited with code 255.