3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $datetime1 = new DateTime(); $datetime2 = new DateTime('2014-01-23 07: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
2 hours, 18 minutes, 10 seconds
Output for 7.0.6
2 years, 3 months, 830 days, 18 hours, 39 minutes, 48 seconds
Output for 7.0.5
2 years, 2 months, 800 days, 7 hours, 57 minutes, 16 seconds
Output for 7.0.4
2 years,1 month, 776 days, 17 hours, 21 minutes, 41 seconds
Output for 7.0.3
2 years,1 month, 784 days, 17 hours, 35 minutes, 12 seconds
Output for 7.0.2
2 years,1 month, 788 days, 4 hours, 10 minutes, 41 seconds
Output for 7.0.1
2 years, 2 months, 790 days, 4 hours, 22 minutes, 06 seconds
Output for 7.0.0
2 years, 2 months, 793 days, 6 hours, 54 minutes, 55 seconds
Output for hhvm-3.12.0
2 years, 2 months, 795 days, 14 hours, 57 minutes, 16 seconds
Output for hhvm-3.10.0
2 years, 2 months, 796 days, 11 hours, 41 minutes, 18 seconds
Output for 5.6.21
2 years, 3 months, 829 days, 13 hours, 43 minutes, 36 seconds
Output for 5.6.20
2 years, 2 months, 807 days, 3 hours, 12 minutes, 22 seconds
Output for 5.6.19
2 years,1 month, 773 days, 15 hours, 25 minutes, 24 seconds
Output for 5.6.18
2 years,1 month, 781 days, 3 hours, 1 minute, 13 seconds
Output for 5.6.17
2 years,1 month, 785 days, 22 hours, 4 minutes, 20 seconds
Output for 5.6.16
2 years, 2 months, 794 days, 8 hours, 38 minutes, 44 seconds
Output for 5.6.15
2 years, 2 months, 795 days, 9 hours, 33 minutes, 06 seconds
Output for 5.6.14
2 years, 2 months, 799 days, 12 hours, 13 minutes, 07 seconds
Output for 5.6.13
2 years, 2 months, 812 days, 16 hours, 43 seconds
Output for 5.6.12
2 years, 2 months, 817 days, 5 hours, 8 minutes, 20 seconds
Output for 5.6.11
2 years, 2 months, 820 days, 12 hours, 24 minutes, 21 seconds
Output for 5.6.10
2 years, 3 months, 822 days, 14 hours, 4 minutes, 13 seconds
Output for 5.6.9
2 years, 3 months, 824 days, 19 hours, 12 minutes, 36 seconds
Output for 5.6.8
2 years, 3 months, 827 days, 2 hours, 45 minutes, 34 seconds
Output for 5.6.7
2 years, 4 months, 852 days, 13 hours, 26 minutes, 38 seconds
Output for 5.5.35
2 years, 3 months, 849 days, 17 hours, 02 seconds
Output for 5.5.34
2 years, 2 months, 808 days, 9 hours, 7 minutes, 32 seconds
Output for 5.5.33
2 years,1 month, 775 days, 4 hours, 17 minutes, 55 seconds
Output for 5.5.32
2 years,1 month, 783 days, 9 hours, 54 minutes, 59 seconds
Output for 5.5.31
2 years,1 month, 787 days, 57 minutes, 37 seconds
Output for 5.5.30
2 years, 2 months, 798 days, 11 hours, 35 minutes, 27 seconds
Output for 5.5.29
2 years, 2 months, 814 days, 6 hours, 6 minutes, 36 seconds
Output for 5.5.28
2 years, 2 months, 818 days, 8 hours, 21 minutes, 33 seconds
Output for 5.5.27
2 years, 2 months, 819 days, 10 hours, 56 minutes, 29 seconds
Output for 5.5.26
2 years, 3 months, 823 days, 16 hours, 21 minutes, 23 seconds
Output for 5.5.25
2 years, 3 months, 825 days, 22 hours, 28 minutes, 58 seconds
Output for 5.5.24
2 years, 3 months, 828 days, 6 hours, 2 minutes, 21 seconds
Output for 5.4.45
1 year, 9 months, 653 days, 18 hours, 13 minutes, 19 seconds
Output for 5.4.44
1 year, 9 months, 653 days, 18 hours, 13 minutes, 20 seconds
Output for 5.4.42 - 5.4.43
1 year, 9 months, 653 days, 18 hours, 13 minutes, 22 seconds
Output for 5.4.40 - 5.4.41
1 year, 9 months, 653 days, 18 hours, 13 minutes, 23 seconds
Output for 5.4.38 - 5.4.39
1 year, 9 months, 653 days, 18 hours, 13 minutes, 24 seconds
Output for 5.4.36 - 5.4.37
1 year, 9 months, 653 days, 18 hours, 13 minutes, 25 seconds
Output for 5.4.35
1 year, 9 months, 653 days, 18 hours, 13 minutes, 26 seconds
Output for 5.3.29, 5.4.32 - 5.4.34
1 year, 9 months, 653 days, 18 hours, 13 minutes, 27 seconds
Output for 5.4.29 - 5.4.31
1 year, 9 months, 653 days, 18 hours, 13 minutes, 28 seconds
Output for 5.4.25 - 5.4.28
1 year, 9 months, 653 days, 18 hours, 13 minutes, 29 seconds
Output for 5.3.28, 5.4.23 - 5.4.24
1 year, 9 months, 653 days, 18 hours, 13 minutes, 30 seconds
Output for 5.4.20 - 5.4.22
1 year, 9 months, 653 days, 18 hours, 13 minutes, 31 seconds
Output for 5.3.27, 5.4.17 - 5.4.19
1 year, 9 months, 653 days, 18 hours, 13 minutes, 32 seconds
Output for 5.3.24 - 5.3.26, 5.4.13 - 5.4.16
1 year, 9 months, 653 days, 18 hours, 13 minutes, 33 seconds
Output for 5.3.20 - 5.3.23, 5.4.10 - 5.4.12
1 year, 9 months, 653 days, 18 hours, 13 minutes, 34 seconds
Output for 5.3.17 - 5.3.19, 5.4.6 - 5.4.9
1 year, 9 months, 653 days, 18 hours, 13 minutes, 35 seconds
Output for 5.3.14 - 5.3.16, 5.4.3 - 5.4.5
1 year, 9 months, 653 days, 18 hours, 13 minutes, 36 seconds
Output for 5.3.10 - 5.3.13, 5.4.0 - 5.4.2
1 year, 9 months, 653 days, 18 hours, 13 minutes, 37 seconds
Output for 5.3.5 - 5.3.9
1 year, 9 months, 653 days, 18 hours, 13 minutes, 38 seconds
Output for 5.3.2 - 5.3.4
1 year, 9 months, 653 days, 18 hours, 13 minutes, 39 seconds
Output for 5.3.0 - 5.3.1
1 year, 9 months, 653 days, 18 hours, 13 minutes, 40 seconds
Output for 5.2.0 - 5.2.17
Fatal error: Call to undefined method DateTime::diff() in /in/68W7l on line 4
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/68W7l 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/68W7l 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/68W7l on line 2