3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $datetime1 = new DateTime(); $datetime2 = new DateTime('2014-03-21 23:37:00'); $interval = $datetime1->diff($datetime2); $elapsed = $interval->format('%y years, %m months, %a days, %h hours, %i minutes, %S seconds'); $elapsed = str_replace(array('0 years,', ' 0 months,', ' 0 days,', ' 0 hours,', ' 0 minutes,'), '', $elapsed); $elapsed = str_replace(array('1 years, ', ' 1 months, ', ' 1 days, ', ' 1 hours, ', ' 1 minutes'), array('1 year, ', '1 month, ', ' 1 day, ', ' 1 hour, ', ' 1 minute'), $elapsed); echo $elapsed;
Output for 5.6.28, 7.0.14 - 7.1.0
4 hours, 28 minutes, 52 seconds
Output for 7.0.6
2 years,1 month, 773 days, 2 hours, 39 minutes, 43 seconds
Output for 7.0.5
2 years, 742 days, 15 hours, 54 minutes, 43 seconds
Output for 7.0.4
1 year, 11 months, 719 days, 1 hour, 23 minutes, 37 seconds
Output for 7.0.3
1 year, 11 months, 727 days, 1 hour, 35 minutes, 55 seconds
Output for 7.0.2
1 year, 11 months, 730 days, 12 hours, 10 minutes, 49 seconds
Output for 7.0.1
2 years, 732 days, 12 hours, 22 minutes, 37 seconds
Output for 7.0.0
2 years, 735 days, 14 hours, 53 minutes, 35 seconds
Output for hhvm-3.12.0
1 year, 11 months, 720 days, 5 hours, 59 minutes, 05 seconds
Output for hhvm-3.10.0
2 years, 738 days, 19 hours, 51 minutes, 43 seconds
Output for 5.6.21
2 years,1 month, 771 days, 21 hours, 42 minutes, 09 seconds
Output for 5.6.20
2 years, 749 days, 11 hours, 9 minutes, 28 seconds
Output for 5.6.19
1 year, 11 months, 715 days, 23 hours, 38 minutes, 47 seconds
Output for 5.6.18
1 year, 11 months, 723 days, 11 hours, 28 minutes, 01 seconds
Output for 5.6.17
1 year, 11 months, 728 days, 6 hours, 4 minutes, 47 seconds
Output for 5.6.16
2 years, 736 days, 16 hours, 38 minutes, 34 seconds
Output for 5.6.15
2 years, 737 days, 17 hours, 32 minutes, 15 seconds
Output for 5.6.14
2 years, 741 days, 20 hours, 10 minutes, 36 seconds
Output for 5.6.13
2 years, 754 days, 23 hours, 58 minutes, 31 seconds
Output for 5.6.12
2 years, 759 days, 13 hours, 6 minutes, 58 seconds
Output for 5.6.11
2 years,1 month, 762 days, 20 hours, 23 minutes, 12 seconds
Output for 5.6.10
2 years,1 month, 764 days, 22 hours, 3 minutes, 09 seconds
Output for 5.6.9
2 years,1 month, 767 days, 3 hours, 12 minutes, 28 seconds
Output for 5.6.8
2 years,1 month, 769 days, 10 hours, 47 minutes, 47 seconds
Output for 5.6.7
2 years, 2 months, 794 days, 21 hours, 30 minutes, 44 seconds
Output for 5.5.35
2 years, 2 months, 792 days, 1 hour, 3 minutes, 34 seconds
Output for 5.5.34
2 years, 750 days, 17 hours, 5 minutes, 17 seconds
Output for 5.5.33
1 year, 11 months, 717 days, 12 hours, 17 minutes, 38 seconds
Output for 5.5.32
1 year, 11 months, 725 days, 17 hours, 58 minutes, 27 seconds
Output for 5.5.31
1 year, 11 months, 729 days, 8 hours, 57 minutes, 43 seconds
Output for 5.5.30
2 years, 740 days, 19 hours, 33 minutes, 47 seconds
Output for 5.5.29
2 years, 756 days, 14 hours, 5 minutes, 24 seconds
Output for 5.5.28
2 years, 760 days, 16 hours, 21 minutes, 27 seconds
Output for 5.5.27
2 years, 761 days, 18 hours, 54 minutes, 40 seconds
Output for 5.5.26
2 years,1 month, 766 days, 20 minutes, 34 seconds
Output for 5.5.25
2 years,1 month, 768 days, 6 hours, 29 minutes, 15 seconds
Output for 5.5.24
2 years,1 month, 770 days, 13 hours, 59 minutes, 41 seconds
Output for 5.4.45
1 year, 5 months, 546 days, 19 hours, 53 minutes, 54 seconds
Output for 5.4.44
1 year, 5 months, 546 days, 19 hours, 53 minutes, 51 seconds
Output for 5.4.43
1 year, 5 months, 546 days, 19 hours, 53 minutes, 48 seconds
Output for 5.4.42
1 year, 5 months, 546 days, 19 hours, 53 minutes, 46 seconds
Output for 5.4.41
1 year, 5 months, 546 days, 19 hours, 53 minutes, 45 seconds
Output for 5.4.40
1 year,1 month, 419 days, 2 hours, 53 minutes, 54 seconds
Output for 5.4.39
1 year,1 month, 419 days, 2 hours, 53 minutes, 53 seconds
Output for 5.4.38
11 months, 345 days, 16 hours, 16 minutes, 33 seconds
Output for 5.4.36 - 5.4.37
10 months, 323 days, 17 hours, 5 minutes, 46 seconds
Output for 5.4.34 - 5.4.35
10 months, 323 days, 17 hours, 5 minutes, 45 seconds
Output for 5.4.32
5 months, 170 days, 1 hour, 14 minutes, 41 seconds
Output for 5.4.31
5 months, 170 days, 1 hour, 14 minutes, 38 seconds
Output for 5.3.29, 5.4.30
5 months, 170 days, 1 hour, 14 minutes, 35 seconds
Output for 5.4.28 - 5.4.29
5 months, 170 days, 1 hour, 14 minutes, 34 seconds
Output for 5.4.27
5 months, 170 days, 1 hour, 14 minutes, 39 seconds
Output for 5.4.11 - 5.4.26
4 hours, 28 minutes, 51 seconds
Output for 5.3.19 - 5.3.28, 5.4.0 - 5.4.10
4 hours, 28 minutes, 50 seconds
Output for 5.3.0 - 5.3.18
4 hours, 28 minutes, 49 seconds
Output for 5.2.0 - 5.2.17
Fatal error: Call to undefined method DateTime::diff() in /in/8s1ZV on line 4
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/8s1ZV 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/8s1ZV 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/8s1ZV on line 2