3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $datetime1 = new DateTime(); $datetime2 = new DateTime('2014-04-12'); $interval = $datetime1->diff($datetime2); $elapsed = $interval->format('%y years, %m months, %d days'); echo $elapsed;
Output for 5.6.28, 7.0.14 - 7.1.0
0 years, 1 months, 0 days
Output for 7.0.6
2 years, 1 months, 9 days
Output for 5.6.14, 7.0.5
2 years, 0 months, 2 days
Output for 7.0.4
1 years, 10 months, 28 days
Output for 7.0.3
1 years, 11 months, 6 days
Output for 7.0.2
1 years, 11 months, 9 days
Output for 7.0.1
1 years, 11 months, 11 days
Output for 7.0.0
1 years, 11 months, 15 days
Output for 5.6.21
2 years, 0 months, 20 days
Output for 5.6.20
1 years, 11 months, 28 days
Output for 5.6.19
1 years, 10 months, 24 days
Output for 5.6.18
1 years, 11 months, 2 days
Output for 5.6.17
1 years, 11 months, 7 days
Output for 5.6.16
1 years, 11 months, 16 days
Output for 5.6.15
1 years, 11 months, 17 days
Output for 5.6.13
2 years, 0 months, 3 days
Output for 5.6.12
2 years, 0 months, 8 days
Output for 5.6.11
2 years, 0 months, 12 days
Output for 5.6.10
2 years, 0 months, 13 days
Output for 5.6.9
2 years, 0 months, 16 days
Output for 5.6.8
2 years, 0 months, 18 days
Output for 5.5.35
2 years, 1 months, 11 days
Output for 5.5.34
1 years, 11 months, 29 days
Output for 5.5.33
1 years, 10 months, 26 days
Output for 5.5.32
1 years, 11 months, 4 days
Output for 5.5.31
1 years, 11 months, 8 days
Output for 5.5.30
1 years, 11 months, 19 days
Output for 5.5.29
2 years, 0 months, 5 days
Output for 5.5.28
2 years, 0 months, 9 days
Output for 5.5.27
2 years, 0 months, 10 days
Output for 5.5.26
2 years, 0 months, 14 days
Output for 5.5.25
2 years, 0 months, 17 days
Output for 5.5.24
2 years, 1 months, 12 days
Output for 5.3.0 - 5.4.45
1 years, 7 months, 8 days
Output for 5.2.0 - 5.2.17
Fatal error: Call to undefined method DateTime::diff() in /in/4pXSm on line 4
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/4pXSm 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/4pXSm 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/4pXSm on line 2