3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $diff=date_diff(date_create('1997-1-1'),date_create(date("Y-m-d"))); echo $diff->format("%R%a days"); if ($diff < new DateTime('18 years')){ echo 'Too young!'; } else { echo 'old_enough'; }
based on mgLoA
Output for 5.3.18 - 5.3.29, 5.4.8 - 7.3.0rc2
+6651 daysold_enough
Output for 5.3.0 - 5.3.17, 5.4.0 - 5.4.7
+6651 days Notice: Object of class DateInterval could not be converted to int in /in/vWkqG on line 5 Notice: Object of class DateTime could not be converted to int in /in/vWkqG on line 5 old_enough
Output for 5.0.0 - 5.2.17
Fatal error: Call to undefined function date_diff() in /in/vWkqG on line 3
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: date_diff() in /in/vWkqG on line 3
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: date_diff() in /in/vWkqG on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: date_diff() in /in/vWkqG on line 3