3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $datetime1 = new DateTime(); $datetime2 = new DateTime('2013-01-03 17:13:00'); $interval = $datetime1->diff($datetime2); //$elapsed = $interval->format('%y years, %m months, %a days, %h hours, %i minutes, %S seconds'); $elapsed = $interval->format('%h hours'); echo $elapsed;
Output for 5.6.11, 5.6.28, 7.0.12 - 7.1.0
15 hours
Output for 5.5.35, 7.0.4, 7.0.6
21 hours
Output for 7.0.0, 7.0.5
10 hours
Output for 5.6.9, 7.0.3
22 hours
Output for 5.5.31, 7.0.2
4 hours
Output for 5.5.33, 7.0.1
8 hours
Output for 5.6.21
16 hours
Output for 5.5.24, 5.5.29, 5.6.12, 5.6.20
9 hours
Output for 5.6.19
5 hours
Output for 5.5.27, 5.5.30, 5.6.14, 5.6.18
14 hours
Output for 5.5.25, 5.6.17
2 hours
Output for 5.5.34, 5.6.16
11 hours
Output for 5.5.28, 5.6.15
12 hours
Output for 5.3.0 - 5.4.45, 5.6.13
18 hours
Output for 5.5.32, 5.6.10
17 hours
Output for 5.6.8
6 hours
Output for 5.5.26
20 hours
Output for 5.2.0 - 5.2.17
Fatal error: Call to undefined method DateTime::diff() in /in/IIoLT on line 4
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/IIoLT on line 2
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: datetime in /in/IIoLT on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: datetime in /in/IIoLT on line 2