3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $post_timestamp = '2014-03-09 20:46:51+04:00'; $pc_time = 'now'; $post = new DateTime($post_timestamp); $pc = new DateTime($pc_time); $diff = $post->diff($pc); $years = $diff->y; $months = $diff->m; $days = $diff->d; $hours = $diff->h; $minutes = $diff->i; $seconds = $diff->s; echo sprintf('Time Difference %s years, %s months, %s days, %s hours, %s minutes, %s seconds', $years, $months, $days, $hours, $minutes, $seconds);
Output for 5.6.28, 7.0.14 - 7.1.0
Time Difference 0 years, 0 months, 0 days, 0 hours, 48 minutes, 14 seconds
Output for 7.0.6
Time Difference 2 years, 1 months, 23 days, 23 hours, 34 minutes, 14 seconds
Output for 7.0.5
Time Difference 2 years, 0 months, 24 days, 11 hours, 59 minutes, 56 seconds
Output for 7.0.4
Time Difference 2 years, 0 months, 1 days, 0 hours, 46 minutes, 16 seconds
Output for 7.0.3
Time Difference 2 years, 0 months, 9 days, 1 hours, 54 minutes, 1 seconds
Output for 7.0.2
Time Difference 2 years, 0 months, 13 days, 8 hours, 1 minutes, 23 seconds
Output for 7.0.1
Time Difference 2 years, 0 months, 14 days, 11 hours, 41 minutes, 50 seconds
Output for 7.0.0
Time Difference 2 years, 0 months, 17 days, 12 hours, 38 minutes, 12 seconds
Output for hhvm-3.12.0
Time Difference 2 years, 0 months, 3 days, 16 hours, 8 minutes, 55 seconds
Output for hhvm-3.10.0
Time Difference 2 years, 0 months, 21 days, 6 hours, 49 minutes, 49 seconds
Output for 5.6.21
Time Difference 2 years, 1 months, 22 days, 18 hours, 43 minutes, 39 seconds
Output for 5.6.20
Time Difference 2 years, 1 months, 0 days, 10 hours, 59 minutes, 17 seconds
Output for 5.6.19
Time Difference 1 years, 11 months, 27 days, 8 hours, 57 minutes, 21 seconds
Output for 5.6.18
Time Difference 2 years, 0 months, 5 days, 17 hours, 40 minutes, 24 seconds
Output for 5.6.17
Time Difference 2 years, 0 months, 10 days, 5 hours, 20 minutes, 9 seconds
Output for 5.6.16
Time Difference 2 years, 0 months, 18 days, 13 hours, 25 minutes, 31 seconds
Output for 5.6.15
Time Difference 2 years, 0 months, 19 days, 14 hours, 16 minutes, 9 seconds
Output for 5.6.14
Time Difference 2 years, 0 months, 23 days, 16 hours, 7 minutes, 38 seconds
Output for 5.6.13
Time Difference 2 years, 1 months, 5 days, 20 hours, 31 minutes, 4 seconds
Output for 5.6.12
Time Difference 2 years, 1 months, 10 days, 11 hours, 0 minutes, 18 seconds
Output for 5.6.11
Time Difference 2 years, 1 months, 14 days, 17 hours, 22 minutes, 10 seconds
Output for 5.6.10
Time Difference 2 years, 1 months, 15 days, 19 hours, 25 minutes, 35 seconds
Output for 5.6.9
Time Difference 2 years, 1 months, 18 days, 0 hours, 35 minutes, 35 seconds
Output for 5.6.8
Time Difference 2 years, 1 months, 20 days, 9 hours, 28 minutes, 8 seconds
Output for 5.5.35
Time Difference 2 years, 2 months, 13 days, 1 hours, 36 minutes, 44 seconds
Output for 5.5.34
Time Difference 2 years, 1 months, 1 days, 13 hours, 11 minutes, 0 seconds
Output for 5.5.33
Time Difference 1 years, 11 months, 28 days, 11 hours, 39 minutes, 20 seconds
Output for 5.5.32
Time Difference 2 years, 0 months, 7 days, 21 hours, 35 minutes, 11 seconds
Output for 5.5.31
Time Difference 2 years, 0 months, 11 days, 8 hours, 21 minutes, 22 seconds
Output for 5.5.30
Time Difference 2 years, 0 months, 22 days, 16 hours, 9 minutes, 40 seconds
Output for 5.5.29
Time Difference 2 years, 1 months, 7 days, 10 hours, 54 minutes, 48 seconds
Output for 5.5.28
Time Difference 2 years, 1 months, 11 days, 14 hours, 13 minutes, 39 seconds
Output for 5.5.27
Time Difference 2 years, 1 months, 12 days, 16 hours, 0 minutes, 57 seconds
Output for 5.5.26
Time Difference 2 years, 1 months, 16 days, 22 hours, 8 minutes, 18 seconds
Output for 5.5.25
Time Difference 2 years, 1 months, 19 days, 5 hours, 0 minutes, 49 seconds
Output for 5.5.24
Time Difference 2 years, 2 months, 14 days, 11 hours, 33 minutes, 51 seconds
Output for 5.4.39 - 5.4.45
Time Difference 1 years, 7 months, 26 days, 7 hours, 42 minutes, 19 seconds
Output for 5.4.29 - 5.4.38
Time Difference 1 years, 7 months, 26 days, 7 hours, 42 minutes, 20 seconds
Output for 5.4.22 - 5.4.28
Time Difference 1 years, 7 months, 26 days, 7 hours, 42 minutes, 21 seconds
Output for 5.4.13 - 5.4.21
Time Difference 1 years, 7 months, 26 days, 7 hours, 42 minutes, 22 seconds
Output for 5.4.4 - 5.4.12
Time Difference 1 years, 7 months, 26 days, 7 hours, 42 minutes, 23 seconds
Output for 5.3.25 - 5.4.3
Time Difference 1 years, 7 months, 26 days, 7 hours, 42 minutes, 24 seconds
Output for 5.3.17 - 5.3.24
Time Difference 1 years, 7 months, 26 days, 7 hours, 42 minutes, 25 seconds
Output for 5.3.7 - 5.3.16
Time Difference 1 years, 7 months, 26 days, 7 hours, 42 minutes, 26 seconds
Output for 5.3.0 - 5.3.6
Time Difference 1 years, 7 months, 26 days, 7 hours, 42 minutes, 27 seconds
Output for 5.2.0 - 5.2.17
Fatal error: Call to undefined method DateTime::diff() in /in/cuAiU on line 8
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/cuAiU on line 5
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: datetime in /in/cuAiU on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: datetime in /in/cuAiU on line 5