3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $datetime1 = new DateTime(); $datetime2 = new DateTime('2014-03-10 17:13: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
8 hours, 1 minute, 28 seconds
Output for 7.0.6
2 years,1 month, 784 days, 17 hours, 47 minutes, 08 seconds
Output for 7.0.5
2 years, 754 days, 6 hours, 29 minutes, 42 seconds
Output for 7.0.4
1 year, 11 months, 730 days, 17 hours, 12 minutes, 15 seconds
Output for 7.0.3
2 years, 738 days, 17 hours, 52 minutes, 44 seconds
Output for 7.0.2
2 years, 742 days, 23 hours, 50 minutes, 19 seconds
Output for 7.0.1
2 years, 744 days, 4 hours, 22 minutes, 08 seconds
Output for 7.0.0
2 years, 747 days, 5 hours, 53 minutes, 59 seconds
Output for 5.6.21
2 years,1 month, 783 days, 13 hours, 6 minutes, 28 seconds
Output for 5.6.20
2 years, 761 days, 5 hours, 30 minutes, 15 seconds
Output for 5.6.19
1 year, 11 months, 728 days, 1 hour, 18 minutes, 06 seconds
Output for 5.6.18
2 years, 735 days, 9 hours, 47 minutes, 44 seconds
Output for 5.6.17
2 years, 739 days, 22 hours, 5 minutes, 18 seconds
Output for 5.6.16
2 years, 748 days, 7 hours, 51 minutes, 19 seconds
Output for 5.6.15
2 years, 749 days, 8 hours, 46 minutes, 21 seconds
Output for 5.6.14
2 years, 753 days, 11 hours, 3 minutes, 54 seconds
Output for 5.6.13
2 years,1 month, 766 days, 14 hours, 59 minutes, 23 seconds
Output for 5.6.12
2 years,1 month, 771 days, 4 hours, 50 minutes, 56 seconds
Output for 5.6.11
2 years,1 month, 774 days, 11 hours, 50 minutes, 43 seconds
Output for 5.6.10
2 years,1 month, 776 days, 13 hours, 35 minutes, 57 seconds
Output for 5.6.9
2 years,1 month, 778 days, 18 hours, 36 minutes, 00 seconds
Output for 5.6.8
2 years,1 month, 781 days, 2 hours, 45 minutes, 42 seconds
Output for 5.5.35
2 years, 2 months, 803 days, 16 hours, 53 minutes, 18 seconds
Output for 5.5.34
2 years,1 month, 762 days, 7 hours, 51 minutes, 51 seconds
Output for 5.5.33
1 year, 11 months, 729 days, 4 hours, 14 minutes, 06 seconds
Output for 5.5.32
2 years, 737 days, 11 hours, 10 minutes, 31 seconds
Output for 5.5.31
2 years, 741 days, 49 minutes, 01 seconds
Output for 5.5.30
2 years, 752 days, 10 hours, 42 minutes, 46 seconds
Output for 5.5.29
2 years,1 month, 768 days, 5 hours, 7 minutes, 18 seconds
Output for 5.5.28
2 years,1 month, 772 days, 8 hours, 9 minutes, 23 seconds
Output for 5.5.27
2 years,1 month, 773 days, 10 hours, 32 minutes, 07 seconds
Output for 5.5.26
2 years,1 month, 777 days, 16 hours, 4 minutes, 19 seconds
Output for 5.5.25
2 years,1 month, 779 days, 22 hours, 29 minutes, 08 seconds
Output for 5.5.24
2 years, 2 months, 805 days, 5 hours, 41 minutes, 48 seconds
Output for 5.4.45
1 year, 6 months, 559 days, 5 hours, 29 minutes, 17 seconds
Output for 5.4.44
1 year, 5 months, 540 days, 8 hours, 49 minutes, 22 seconds
Output for 5.4.43
1 year, 5 months, 540 days, 8 hours, 49 minutes, 19 seconds
Output for 5.4.42
1 year, 5 months, 540 days, 8 hours, 49 minutes, 18 seconds
Output for 5.4.41
1 year, 2 months, 441 days, 6 hours, 10 minutes, 09 seconds
Output for 5.4.40
1 year,1 month, 425 days, 23 hours, 25 minutes, 03 seconds
Output for 5.4.39
1 year,1 month, 425 days, 23 hours, 25 minutes, 02 seconds
Output for 5.4.38
11 months, 356 days, 20 hours, 18 minutes, 25 seconds
Output for 5.4.36 - 5.4.37
10 months, 334 days, 16 hours, 7 minutes, 17 seconds
Output for 5.4.34 - 5.4.35
10 months, 334 days, 16 hours, 7 minutes, 16 seconds
Output for 5.4.32
5 months, 180 days, 15 hours, 11 minutes, 46 seconds
Output for 5.4.27, 5.4.31
5 months, 180 days, 15 hours, 11 minutes, 43 seconds
Output for 5.3.29, 5.4.30
5 months, 180 days, 15 hours, 11 minutes, 39 seconds
Output for 5.4.28 - 5.4.29
5 months, 180 days, 15 hours, 11 minutes, 38 seconds
Output for 5.4.24 - 5.4.26
8 hours, 1 minute, 27 seconds
Output for 5.4.2 - 5.4.23
8 hours, 1 minute, 26 seconds
Output for 5.3.10 - 5.3.28, 5.4.0 - 5.4.1
8 hours, 1 minute, 25 seconds
Output for 5.3.0 - 5.3.9
8 hours, 1 minute, 24 seconds
Output for 5.2.0 - 5.2.17
Fatal error: Call to undefined method DateTime::diff() in /in/5jgtg on line 4
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/5jgtg 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/5jgtg 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/5jgtg on line 2