3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $datetime1 = new DateTime(); $datetime2 = new DateTime('2014-09-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 Me5IT
Output for 5.6.28, 7.0.14 - 7.1.0
3 hours, 14 seconds
Output for 7.0.6
1 year, 7 months, 595 days, 14 hours, 50 minutes, 34 seconds
Output for 7.0.5
1 year, 6 months, 565 days, 3 hours, 47 minutes, 38 seconds
Output for 7.0.4
1 year, 5 months, 541 days, 14 hours, 3 minutes, 45 seconds
Output for 7.0.3
1 year, 6 months, 549 days, 14 hours, 35 minutes, 52 seconds
Output for 7.0.2
1 year, 6 months, 553 days, 20 hours, 21 minutes, 05 seconds
Output for 7.0.1
1 year, 6 months, 555 days, 1 hour, 22 minutes, 53 seconds
Output for 7.0.0
1 year, 6 months, 558 days, 3 hours, 3 minutes, 23 seconds
Output for 5.6.21
1 year, 7 months, 594 days, 10 hours, 9 minutes, 50 seconds
Output for 5.6.20
1 year, 6 months, 572 days, 2 hours, 37 minutes, 38 seconds
Output for 5.6.19
1 year, 5 months, 538 days, 22 hours, 9 minutes, 38 seconds
Output for 5.6.18
1 year, 5 months, 546 days, 5 hours, 55 minutes, 02 seconds
Output for 5.6.17
1 year, 6 months, 550 days, 18 hours, 54 minutes, 16 seconds
Output for 5.6.16
1 year, 6 months, 559 days, 4 hours, 48 minutes, 43 seconds
Output for 5.6.15
1 year, 6 months, 560 days, 5 hours, 42 minutes, 00 seconds
Output for 5.6.14
1 year, 6 months, 564 days, 8 hours, 16 minutes, 21 seconds
Output for 5.6.13
1 year, 6 months, 577 days, 12 hours, 11 minutes, 49 seconds
Output for 5.6.12
1 year, 7 months, 582 days, 1 hour, 47 minutes, 59 seconds
Output for 5.6.11
1 year, 7 months, 585 days, 8 hours, 47 minutes, 14 seconds
Output for 5.6.10
1 year, 7 months, 587 days, 10 hours, 38 minutes, 35 seconds
Output for 5.6.9
1 year, 7 months, 589 days, 15 hours, 35 minutes, 48 seconds
Output for 5.6.8
1 year, 7 months, 591 days, 23 hours, 36 minutes, 08 seconds
Output for 5.6.7
1 year, 8 months, 617 days, 17 hours, 43 minutes, 59 seconds
Output for 5.5.35
1 year, 8 months, 614 days, 13 hours, 51 minutes, 17 seconds
Output for 5.5.34
1 year, 6 months, 573 days, 5 hours, 4 minutes, 03 seconds
Output for 5.5.33
1 year, 5 months, 540 days, 59 minutes, 29 seconds
Output for 5.5.32
1 year, 6 months, 548 days, 7 hours, 46 minutes, 40 seconds
Output for 5.5.31
1 year, 6 months, 551 days, 21 hours, 41 minutes, 27 seconds
Output for 5.5.30
1 year, 6 months, 563 days, 7 hours, 50 minutes, 20 seconds
Output for 5.5.29
1 year, 7 months, 579 days, 2 hours, 16 minutes, 46 seconds
Output for 5.5.28
1 year, 7 months, 583 days, 4 hours, 54 minutes, 02 seconds
Output for 5.5.27
1 year, 7 months, 584 days, 7 hours, 24 minutes, 32 seconds
Output for 5.5.26
1 year, 7 months, 588 days, 13 hours, 4 minutes, 21 seconds
Output for 5.5.25
1 year, 7 months, 590 days, 19 hours, 7 minutes, 38 seconds
Output for 5.5.24
1 year, 8 months, 616 days, 2 hours, 2 minutes, 51 seconds
Output for 5.4.42 - 5.4.45
1 year, 392 days, 4 hours, 33 minutes, 21 seconds
Output for 5.4.32 - 5.4.41
1 year, 392 days, 4 hours, 33 minutes, 22 seconds
Output for 5.4.23 - 5.4.31
1 year, 392 days, 4 hours, 33 minutes, 23 seconds
Output for 5.4.15 - 5.4.22
1 year, 392 days, 4 hours, 33 minutes, 24 seconds
Output for 5.4.6 - 5.4.14
1 year, 392 days, 4 hours, 33 minutes, 25 seconds
Output for 5.4.1 - 5.4.5
1 year, 392 days, 4 hours, 33 minutes, 26 seconds
Output for 5.3.27 - 5.4.0
1 year, 392 days, 4 hours, 33 minutes, 27 seconds
Output for 5.3.18 - 5.3.26
1 year, 392 days, 4 hours, 33 minutes, 28 seconds
Output for 5.3.8 - 5.3.17
1 year, 392 days, 4 hours, 33 minutes, 29 seconds
Output for 5.3.0 - 5.3.7
1 year, 392 days, 4 hours, 33 minutes, 30 seconds
Output for 5.2.0 - 5.2.17
Fatal error: Call to undefined method DateTime::diff() in /in/RGhPG on line 4
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/RGhPG 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/RGhPG 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/RGhPG on line 2