3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $datetime1 = new DateTime(); $datetime2 = new DateTime('2014-09-15 16:30: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); echo $elapsed;
based on YEIdN
Output for 5.6.28, 7.0.14 - 7.1.0
2 hours, 30 minutes, 32 seconds
Output for 7.0.6
1 years, 7 months, 595 days, 10 hours, 46 minutes, 16 seconds
Output for 7.0.5
1 years, 6 months, 565 days, 28 seconds
Output for 7.0.4
1 years, 5 months, 541 days, 9 hours, 38 minutes, 08 seconds
Output for 7.0.3
1 years, 6 months, 549 days, 9 hours, 50 minutes, 03 seconds
Output for 7.0.2
1 years, 6 months, 552 days, 20 hours, 23 minutes, 16 seconds
Output for 7.0.1
1 years, 6 months, 554 days, 20 hours, 36 minutes, 42 seconds
Output for 7.0.0
1 years, 6 months, 557 days, -1 hours, 1 minutes, 09 seconds
Output for hhvm-3.12.0
1 years, 6 months, 558 days, 21 hours, 2 minutes, 21 seconds
Output for hhvm-3.10.0
1 years, 6 months, 561 days, 4 hours, 57 minutes, 02 seconds
Output for 5.6.21
1 years, 7 months, 594 days, 5 hours, 49 minutes, 05 seconds
Output for 5.6.20
1 years, 6 months, 571 days, 19 hours, 13 minutes, 31 seconds
Output for 5.6.19
1 years, 5 months, 538 days, 8 hours, 10 minutes, 43 seconds
Output for 5.6.18
1 years, 5 months, 545 days, 20 hours, 15 minutes, 45 seconds
Output for 5.6.17
1 years, 6 months, 550 days, 14 hours, 18 minutes, 45 seconds
Output for 5.6.16
1 years, 6 months, 559 days, 46 minutes, 36 seconds
Output for 5.6.15
1 years, 6 months, 560 days, 1 hours, 39 minutes, 21 seconds
Output for 5.6.14
1 years, 6 months, 564 days, 4 hours, 15 minutes, 21 seconds
Output for 5.6.13
1 years, 6 months, 577 days, 8 hours, 12 minutes, 17 seconds
Output for 5.6.12
1 years, 7 months, 581 days, 21 hours, 16 minutes, 10 seconds
Output for 5.6.11
1 years, 7 months, 585 days, 4 hours, 32 minutes, 58 seconds
Output for 5.6.10
1 years, 7 months, 587 days, 6 hours, 11 minutes, 27 seconds
Output for 5.6.9
1 years, 7 months, 589 days, 11 hours, 22 minutes, 56 seconds
Output for 5.6.8
1 years, 7 months, 591 days, 19 hours, 5 minutes, 48 seconds
Output for 5.6.7
1 years, 8 months, 617 days, 6 hours, 22 minutes, 44 seconds
Output for 5.5.35
1 years, 8 months, 614 days, 9 hours, 13 minutes, 36 seconds
Output for 5.5.34
1 years, 6 months, 573 days, 1 hours, 10 minutes, 34 seconds
Output for 5.5.33
1 years, 5 months, 539 days, 20 hours, 29 minutes, 46 seconds
Output for 5.5.32
1 years, 6 months, 548 days, 2 hours, 12 minutes, 32 seconds
Output for 5.5.31
1 years, 6 months, 551 days, 17 hours, 10 minutes, 50 seconds
Output for 5.5.30
1 years, 6 months, 563 days, 3 hours, 40 minutes, 49 seconds
Output for 5.5.29
1 years, 7 months, 578 days, 22 hours, 12 minutes, 44 seconds
Output for 5.5.28
1 years, 7 months, 583 days, 33 minutes, 48 seconds
Output for 5.5.27
1 years, 7 months, 584 days, 3 hours, 2 minutes, 08 seconds
Output for 5.5.26
1 years, 7 months, 588 days, 8 hours, 40 minutes, 06 seconds
Output for 5.5.25
1 years, 7 months, 590 days, 14 hours, 40 minutes, 49 seconds
Output for 5.5.24
1 years, 7 months, 592 days, 22 hours, 6 minutes, 37 seconds
Output for 5.4.45
1 years, 370 days, 21 hours, 13 minutes, 54 seconds
Output for 5.4.44
1 years, 370 days, 21 hours, 13 minutes, 50 seconds
Output for 5.4.43
1 years, 370 days, 21 hours, 13 minutes, 43 seconds
Output for 5.4.42
1 years, 370 days, 21 hours, 13 minutes, 39 seconds
Output for 5.4.41
1 years, 370 days, 21 hours, 13 minutes, 33 seconds
Output for 5.4.40
1 years, 370 days, 21 hours, 13 minutes, 25 seconds
Output for 5.4.39
1 years, 370 days, 21 hours, 13 minutes, 17 seconds
Output for 5.4.38
5 months, 180 days, 1 hours, 46 minutes, 49 seconds
Output for 5.4.36 - 5.4.37
5 months, 180 days, 1 hours, 46 minutes, 42 seconds
Output for 5.4.34 - 5.4.35
5 months, 180 days, 1 hours, 46 minutes, 41 seconds
Output for 5.4.26 - 5.4.32
2 hours, 30 minutes, 28 seconds
Output for 5.4.5 - 5.4.25
2 hours, 30 minutes, 27 seconds
Output for 5.3.14 - 5.4.4
2 hours, 30 minutes, 26 seconds
Output for 5.3.0 - 5.3.13
2 hours, 30 minutes, 25 seconds
Output for 5.2.0 - 5.2.17
Fatal error: Call to undefined method DateTime::diff() in /in/eEjAZ on line 4
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/eEjAZ 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/eEjAZ 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/eEjAZ on line 2