3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $datetime1 = new DateTime(); $datetime2 = new DateTime('2014-06-15 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;
based on 0rn2p
Output for 5.6.28, 7.0.14 - 7.1.0
2 months, 91 days, 20 hours, 12 minutes, 51 seconds
Output for 7.0.6
1 year, 10 months, 687 days, 14 hours, 50 minutes, 08 seconds
Output for 7.0.5
1 year, 9 months, 657 days, 3 hours, 47 minutes, 14 seconds
Output for 7.0.4
1 year, 8 months, 633 days, 14 hours, 3 minutes, 20 seconds
Output for 7.0.3
1 year, 9 months, 641 days, 14 hours, 35 minutes, 25 seconds
Output for 7.0.2
1 year, 9 months, 645 days, 20 hours, 20 minutes, 39 seconds
Output for 7.0.1
1 year, 9 months, 647 days, 1 hour, 22 minutes, 29 seconds
Output for 7.0.0
1 year, 9 months, 650 days, 3 hours, 3 minutes, 01 seconds
Output for hhvm-3.12.0
1 year, 9 months, 650 days, 20 hours, 19 minutes, 19 seconds
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.6.21
1 year, 10 months, 686 days, 10 hours, 9 minutes, 22 seconds
Output for 5.6.20
1 year, 9 months, 664 days, 2 hours, 37 minutes, 09 seconds
Output for 5.6.19
1 year, 8 months, 630 days, 22 hours, 9 minutes, 11 seconds
Output for 5.6.18
1 year, 8 months, 638 days, 5 hours, 54 minutes, 32 seconds
Output for 5.6.17
1 year, 9 months, 642 days, 18 hours, 53 minutes, 48 seconds
Output for 5.6.16
1 year, 9 months, 651 days, 4 hours, 48 minutes, 29 seconds
Output for 5.6.15
1 year, 9 months, 652 days, 5 hours, 41 minutes, 38 seconds
Output for 5.6.14
1 year, 9 months, 656 days, 8 hours, 15 minutes, 57 seconds
Output for 5.6.13
1 year, 9 months, 669 days, 12 hours, 11 minutes, 24 seconds
Output for 5.6.12
1 year, 10 months, 674 days, 1 hour, 47 minutes, 32 seconds
Output for 5.6.11
1 year, 10 months, 677 days, 8 hours, 46 minutes, 47 seconds
Output for 5.6.10
1 year, 10 months, 679 days, 10 hours, 38 minutes, 02 seconds
Output for 5.6.9
1 year, 10 months, 681 days, 15 hours, 35 minutes, 22 seconds
Output for 5.6.8
1 year, 10 months, 683 days, 23 hours, 35 minutes, 29 seconds
Output for 5.6.7
1 year, 11 months, 709 days, 17 hours, 42 minutes, 55 seconds
Output for 5.5.35
1 year, 11 months, 706 days, 13 hours, 50 minutes, 51 seconds
Output for 5.5.34
1 year, 9 months, 665 days, 5 hours, 3 minutes, 40 seconds
Output for 5.5.33
1 year, 8 months, 632 days, 59 minutes, 05 seconds
Output for 5.5.32
1 year, 9 months, 640 days, 7 hours, 46 minutes, 15 seconds
Output for 5.5.31
1 year, 9 months, 643 days, 21 hours, 41 minutes, 02 seconds
Output for 5.5.30
1 year, 9 months, 655 days, 7 hours, 49 minutes, 55 seconds
Output for 5.5.29
1 year, 10 months, 671 days, 2 hours, 16 minutes, 22 seconds
Output for 5.5.28
1 year, 10 months, 675 days, 4 hours, 53 minutes, 35 seconds
Output for 5.5.27
1 year, 10 months, 676 days, 7 hours, 24 minutes, 04 seconds
Output for 5.5.26
1 year, 10 months, 680 days, 13 hours, 3 minutes, 54 seconds
Output for 5.5.25
1 year, 10 months, 682 days, 19 hours, 7 minutes, 09 seconds
Output for 5.5.24
1 year, 11 months, 708 days, 2 hours, 2 minutes, 29 seconds
Output for 5.4.45
1 year, 3 months, 462 days, 20 hours, 30 minutes, 52 seconds
Output for 5.4.44
1 year, 3 months, 462 days, 20 hours, 30 minutes, 48 seconds
Output for 5.4.43
1 year, 3 months, 462 days, 20 hours, 30 minutes, 40 seconds
Output for 5.4.42
1 year, 3 months, 462 days, 20 hours, 30 minutes, 36 seconds
Output for 5.4.41
1 year, 3 months, 462 days, 20 hours, 30 minutes, 30 seconds
Output for 5.4.40
1 year, 3 months, 462 days, 20 hours, 30 minutes, 21 seconds
Output for 5.4.39
1 year, 3 months, 462 days, 20 hours, 30 minutes, 13 seconds
Output for 5.4.38
8 months, 272 days, 1 hour, 1 minute, 20 seconds
Output for 5.4.36 - 5.4.37
8 months, 272 days, 1 hour, 1 minute, 12 seconds
Output for 5.4.34 - 5.4.35
8 months, 272 days, 1 hour, 1 minute, 11 seconds
Output for 5.4.31 - 5.4.32
2 months, 91 days, 20 hours, 12 minutes, 55 seconds
Output for 5.4.11 - 5.4.30
2 months, 91 days, 20 hours, 12 minutes, 56 seconds
Output for 5.3.21 - 5.4.10
2 months, 91 days, 20 hours, 12 minutes, 57 seconds
Output for 5.3.1 - 5.3.20
2 months, 91 days, 20 hours, 12 minutes, 58 seconds
Output for 5.3.0
2 months, 91 days, 20 hours, 12 minutes, 59 seconds
Output for 5.2.0 - 5.2.17
Fatal error: Call to undefined method DateTime::diff() in /in/9apWl on line 4
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/9apWl 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/9apWl 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/9apWl on line 2