3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php date_default_timezone_set('Europe/Moscow'); $datetime1 = new DateTime('13-03-01'); $datetime2 = new DateTime('13-04-01'); $datetime3 = new DateTime('13-03-02'); $datetime4 = new DateTime('13-04-02'); $interval = $datetime2->diff($datetime1); echo $interval->format('%m month, %d days'), '<br>'; //1 month, 3 days $interval = $datetime4->diff($datetime3); echo $interval->format('%m month, %d days'); //1 month, 0 days
Output for 5.3.0 - 7.1.0
1 month, 3 days<br>1 month, 0 days
Output for 5.2.0 - 5.2.17
Fatal error: Call to undefined method DateTime::diff() in /in/a38fj on line 11
Process exited with code 255.
Output for 5.1.1 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/a38fj on line 5
Process exited with code 255.
Output for 5.1.0
Fatal error: fatal flex scanner internal error--end of buffer missed in /in/a38fj on line 15
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Fatal error: Call to undefined function date_default_timezone_set() in /in/a38fj on line 3
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: date_default_timezone_set() in /in/a38fj on line 3
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: date_default_timezone_set() in /in/a38fj on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: date_default_timezone_set() in /in/a38fj on line 3