3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $post_timestamp = '2014-03-09 20:46:51'; $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, 3 hours, 53 minutes, 48 seconds
Output for 7.0.7
Time Difference 0 years, 0 months, 0 days, 2 hours, 53 minutes, 48 seconds
Output for 7.0.6
Time Difference 2 years, 1 months, 23 days, 2 hours, 39 minutes, 41 seconds
Output for 7.0.5
Time Difference 2 years, 0 months, 23 days, 16 hours, 13 minutes, 43 seconds
Output for 7.0.4
Time Difference 2 years, 0 months, 0 days, 1 hours, 3 minutes, 27 seconds
Output for 7.0.3
Time Difference 2 years, 0 months, 8 days, 1 hours, 28 minutes, 20 seconds
Output for 7.0.2
Time Difference 2 years, 0 months, 11 days, 12 hours, 12 minutes, 51 seconds
Output for 7.0.1
Time Difference 2 years, 0 months, 13 days, 11 hours, 51 minutes, 10 seconds
Output for 7.0.0
Time Difference 2 years, 0 months, 16 days, 15 hours, 4 minutes, 3 seconds
Output for 5.6.21
Time Difference 2 years, 1 months, 21 days, 21 hours, 44 minutes, 42 seconds
Output for 5.6.20
Time Difference 2 years, 0 months, 30 days, 11 hours, 32 minutes, 57 seconds
Output for 5.6.19
Time Difference 1 years, 11 months, 25 days, 22 hours, 1 minutes, 24 seconds
Output for 5.6.18
Time Difference 2 years, 0 months, 4 days, 10 hours, 27 minutes, 50 seconds
Output for 5.6.17
Time Difference 2 years, 0 months, 9 days, 6 hours, 1 minutes, 44 seconds
Output for 5.6.16
Time Difference 2 years, 0 months, 17 days, 16 hours, 46 minutes, 19 seconds
Output for 5.6.15
Time Difference 2 years, 0 months, 18 days, 17 hours, 36 minutes, 38 seconds
Output for 5.6.14
Time Difference 2 years, 0 months, 22 days, 20 hours, 30 minutes, 13 seconds
Output for 5.6.13
Time Difference 2 years, 1 months, 5 days, 0 hours, 26 minutes, 53 seconds
Output for 5.6.12
Time Difference 2 years, 1 months, 9 days, 13 hours, 26 minutes, 21 seconds
Output for 5.6.11
Time Difference 2 years, 1 months, 12 days, 20 hours, 47 minutes, 38 seconds
Output for 5.6.10
Time Difference 2 years, 1 months, 14 days, 22 hours, 25 minutes, 0 seconds
Output for 5.6.9
Time Difference 2 years, 1 months, 17 days, 3 hours, 21 minutes, 33 seconds
Output for 5.6.8
Time Difference 2 years, 1 months, 19 days, 11 hours, 0 minutes, 38 seconds
Output for 5.6.7
Time Difference 2 years, 2 months, 14 days, 20 hours, 31 minutes, 14 seconds
Output for 5.5.35
Time Difference 2 years, 2 months, 12 days, 0 hours, 51 minutes, 21 seconds
Output for 5.5.34
Time Difference 2 years, 1 months, 0 days, 16 hours, 56 minutes, 58 seconds
Output for 5.5.33
Time Difference 1 years, 11 months, 27 days, 12 hours, 11 minutes, 22 seconds
Output for 5.5.32
Time Difference 2 years, 0 months, 5 days, 21 hours, 16 minutes, 38 seconds
Output for 5.5.31
Time Difference 2 years, 0 months, 10 days, 8 hours, 59 minutes, 8 seconds
Output for 5.5.30
Time Difference 2 years, 0 months, 21 days, 19 hours, 49 minutes, 26 seconds
Output for 5.5.29
Time Difference 2 years, 1 months, 6 days, 14 hours, 23 minutes, 35 seconds
Output for 5.5.28
Time Difference 2 years, 1 months, 10 days, 16 hours, 29 minutes, 47 seconds
Output for 5.5.27
Time Difference 2 years, 1 months, 11 days, 19 hours, 17 minutes, 40 seconds
Output for 5.5.26
Time Difference 2 years, 1 months, 16 days, 0 hours, 37 minutes, 49 seconds
Output for 5.5.25
Time Difference 2 years, 1 months, 18 days, 6 hours, 42 minutes, 6 seconds
Output for 5.5.24
Time Difference 2 years, 1 months, 20 days, 14 hours, 27 minutes, 37 seconds
Output for 5.4.45
Time Difference 1 years, 6 months, 0 days, 20 hours, 1 minutes, 39 seconds
Output for 5.4.44
Time Difference 1 years, 5 months, 21 days, 0 hours, 51 minutes, 30 seconds
Output for 5.4.43
Time Difference 1 years, 5 months, 21 days, 0 hours, 51 minutes, 27 seconds
Output for 5.4.42
Time Difference 1 years, 5 months, 21 days, 0 hours, 51 minutes, 26 seconds
Output for 5.4.41
Time Difference 1 years, 5 months, 21 days, 0 hours, 51 minutes, 23 seconds
Output for 5.4.39 - 5.4.40
Time Difference 1 years, 5 months, 21 days, 0 hours, 51 minutes, 21 seconds
Output for 5.4.38
Time Difference 0 years, 11 months, 18 days, 17 hours, 2 minutes, 19 seconds
Output for 5.4.37
Time Difference 0 years, 10 months, 26 days, 1 hours, 35 minutes, 37 seconds
Output for 5.4.36
Time Difference 0 years, 10 months, 26 days, 1 hours, 35 minutes, 36 seconds
Output for 5.4.34 - 5.4.35
Time Difference 0 years, 8 months, 5 days, 14 hours, 38 minutes, 17 seconds
Output for 5.4.32
Time Difference 0 years, 5 months, 19 days, 20 hours, 21 minutes, 28 seconds
Output for 5.4.31
Time Difference 0 years, 5 months, 19 days, 20 hours, 21 minutes, 23 seconds
Output for 5.4.29 - 5.4.30
Time Difference 0 years, 5 months, 19 days, 20 hours, 21 minutes, 17 seconds
Output for 5.4.28
Time Difference 0 years, 5 months, 19 days, 20 hours, 21 minutes, 16 seconds
Output for 5.4.27
Time Difference 0 years, 5 months, 19 days, 20 hours, 21 minutes, 24 seconds
Output for 5.4.10 - 5.4.26
Time Difference 0 years, 0 months, 0 days, 3 hours, 53 minutes, 47 seconds
Output for 5.3.19 - 5.3.28, 5.4.0 - 5.4.9
Time Difference 0 years, 0 months, 0 days, 3 hours, 53 minutes, 46 seconds
Output for 5.3.29
Time Difference 0 years, 5 months, 19 days, 20 hours, 21 minutes, 18 seconds
Output for 5.3.0 - 5.3.18
Time Difference 0 years, 0 months, 0 days, 3 hours, 53 minutes, 45 seconds
Output for 5.2.0 - 5.2.17
Fatal error: Call to undefined method DateTime::diff() in /in/Z7FYN on line 8
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/Z7FYN 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/Z7FYN 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/Z7FYN on line 5