3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $date1 = new DateTime('24 June 1940'); $date2 = new DateTime('now'); list($year1, $dayOfYear1) = explode(' ', $date1->format('Y z')); list($year2, $dayOfYear2) = explode(' ', $date2->format('Y z')); $age = $year1 - $year2 - ($dayOfYear1 < $dayOfYear2); print $age;
based on UFo9g
Output for 5.2.0 - 5.4.38, 5.6.28, 7.0.14 - 7.1.0
-75
Output for 5.4.39 - 5.6.21, 7.0.0 - 7.0.6
-76
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/9Lk0E 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/9Lk0E 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/9Lk0E on line 3