3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $date1 = new DateTime("2014-04-24"); $date2 = new DateTime(); $interval = $date2->diff($date1); echo "difference " . $interval->y . " years, " . $interval->m." months, ".$interval->d." days ";
Output for 5.3.0 - 5.3.28, 5.4.0 - 5.4.26, 5.6.28, 7.0.14 - 7.1.0
difference 0 years, 0 months, 20 days
Output for 7.0.6
difference 2 years, 0 months, 9 days
Output for 5.6.14, 7.0.5
difference 1 years, 11 months, 8 days
Output for 7.0.4
difference 1 years, 10 months, 16 days
Output for 7.0.3
difference 1 years, 10 months, 24 days
Output for 7.0.2
difference 1 years, 10 months, 28 days
Output for 7.0.1
difference 1 years, 10 months, 29 days
Output for 7.0.0
difference 1 years, 11 months, 2 days
Output for hhvm-3.12.0
difference 1 years, 10 months, 17 days
Output for hhvm-3.10.0
difference 1 years, 11 months, 6 days
Output for 5.6.21
difference 2 years, 0 months, 8 days
Output for 5.6.20
difference 1 years, 11 months, 15 days
Output for 5.6.19
difference 1 years, 10 months, 13 days
Output for 5.6.18
difference 1 years, 10 months, 21 days
Output for 5.6.17
difference 1 years, 10 months, 25 days
Output for 5.6.16
difference 1 years, 11 months, 3 days
Output for 5.6.15
difference 1 years, 11 months, 5 days
Output for 5.6.13
difference 1 years, 11 months, 21 days
Output for 5.6.12
difference 1 years, 11 months, 25 days
Output for 5.6.11
difference 1 years, 11 months, 29 days
Output for 5.6.10
difference 2 years, 0 months, 1 days
Output for 5.6.9
difference 2 years, 0 months, 3 days
Output for 5.6.8
difference 2 years, 0 months, 5 days
Output for 5.5.35
difference 2 years, 0 months, 28 days
Output for 5.5.34
difference 1 years, 11 months, 16 days
Output for 5.5.33
difference 1 years, 10 months, 14 days
Output for 5.5.32
difference 1 years, 10 months, 23 days
Output for 5.5.31
difference 1 years, 10 months, 26 days
Output for 5.5.30
difference 1 years, 11 months, 7 days
Output for 5.5.29
difference 1 years, 11 months, 22 days
Output for 5.5.28
difference 1 years, 11 months, 26 days
Output for 5.5.27
difference 1 years, 11 months, 28 days
Output for 5.5.26
difference 2 years, 0 months, 2 days
Output for 5.5.25
difference 2 years, 0 months, 4 days
Output for 5.5.24
difference 2 years, 0 months, 29 days
Output for 5.4.44 - 5.4.45
difference 1 years, 4 months, 11 days
Output for 5.4.43
difference 1 years, 2 months, 24 days
Output for 5.4.42
difference 1 years, 2 months, 14 days
Output for 5.4.41
difference 1 years, 1 months, 2 days
Output for 5.4.39 - 5.4.40
difference 1 years, 0 months, 7 days
Output for 5.4.38
difference 0 years, 10 months, 4 days
Output for 5.4.36 - 5.4.37
difference 0 years, 9 months, 11 days
Output for 5.4.34 - 5.4.35
difference 0 years, 6 months, 21 days
Output for 5.3.29, 5.4.27 - 5.4.32
difference 0 years, 4 months, 6 days
Output for 5.2.0 - 5.2.17
Fatal error: Call to undefined method DateTime::diff() in /in/VjXLr on line 6
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/VjXLr 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/VjXLr 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/VjXLr on line 3