3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $now = new DateTime(); $date = new DateTime('2013-01-01 12:13:14'); $interval = $now->diff($date); $elapsed = $interval->format('Прошло: %y лет, %m месяцев, %a дней, %h часов, %i минут, %S секунд'); echo($elapsed);
Output for 5.6.28, 7.0.14 - 7.1.0
Прошло: 0 лет, 4 месяцев, 126 дней, 7 часов, 35 минут, 51 секунд
Output for 5.3.0 - 5.6.22, 7.0.0 - 7.0.7
Прошло: 0 лет, 4 месяцев, 126 дней, 9 часов, 35 минут, 51 секунд
Output for 5.2.0 - 5.2.17
Fatal error: Call to undefined method DateTime::diff() in /in/4pUig on line 5
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/4pUig 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/4pUig 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/4pUig on line 3