3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $datetime1 = new DateTime(); $datetime2 = new DateTime('2015-12-24'); $interval = $datetime1->diff($datetime2); $elapsed = $interval->format('%yyyy-%mm-%dd'); echo $elapsed;
based on 4oLB1
Output for 5.3.0 - 5.3.28, 5.4.0 - 5.4.31, 5.6.28, 7.0.14 - 7.2.0
1yyy-4m-5d
Output for 7.0.6
0yyy-4m-10d
Output for 5.6.14, 7.0.5
0yyy-3m-9d
Output for 7.0.4
0yyy-2m-17d
Output for 7.0.3
0yyy-2m-25d
Output for 7.0.2
0yyy-2m-29d
Output for 7.0.1
0yyy-2m-30d
Output for 5.4.39 - 5.4.45, 7.0.0
0yyy-3m-2d
Output for 5.6.21
0yyy-4m-9d
Output for 5.6.20
0yyy-3m-16d
Output for 5.6.19
0yyy-2m-14d
Output for 5.6.18
0yyy-2m-22d
Output for 5.6.17
0yyy-2m-26d
Output for 5.6.16
0yyy-3m-3d
Output for 5.6.15
0yyy-3m-5d
Output for 5.6.13
0yyy-3m-22d
Output for 5.6.12
0yyy-3m-26d
Output for 5.6.11
0yyy-3m-30d
Output for 5.6.10
0yyy-4m-1d
Output for 5.6.9
0yyy-4m-3d
Output for 5.6.8
0yyy-4m-5d
Output for 5.5.35
0yyy-4m-29d
Output for 5.5.34
0yyy-3m-17d
Output for 5.5.33
0yyy-2m-15d
Output for 5.5.32
0yyy-2m-24d
Output for 5.5.31
0yyy-2m-27d
Output for 5.5.30
0yyy-3m-8d
Output for 5.5.29
0yyy-3m-23d
Output for 5.5.28
0yyy-3m-27d
Output for 5.5.27
0yyy-3m-29d
Output for 5.5.26
0yyy-4m-2d
Output for 5.5.25
0yyy-4m-4d
Output for 5.5.24
0yyy-4m-30d
Output for 5.4.34 - 5.4.38
0yyy-9m-18d
Output for 5.3.29, 5.4.32
1yyy-3m-20d
Output for 5.2.0 - 5.2.17
Fatal error: Call to undefined method DateTime::diff() in /in/6sXah on line 4
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/6sXah 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/6sXah 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/6sXah on line 2