3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $currentDate = new DateTime(); $targetDate = new DateTime('2015-03-05 11:11:11'); $interval = $currentDate->diff($targetDate); // var_dump($interval); // Uncomment and isset will give the expected response var_dump($interval->y); var_dump($interval->m); var_dump(isset($interval->y)); var_dump(isset($interval->m));
Output for 7.1.8 - 7.2.6
int(2) int(5) bool(true) bool(true)
Output for 7.0.14 - 7.1.7
int(1) int(11) bool(true) bool(true)
Output for 5.3.0 - 5.6.30, hhvm-3.10.1 - 3.17.3, 7.0.0 - 7.0.13
int(1) int(11) bool(false) bool(false)
Output for 5.2.0 - 5.2.17
Fatal error: Call to undefined method DateTime::diff() in /in/D7bcM on line 5
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/D7bcM on line 3
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: datetime in /in/D7bcM on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: datetime in /in/D7bcM on line 3