3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $datetime1 = new DateTime(); $datetime2 = new DateTime('2013-01-03 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;
Output for 5.6.28, 7.0.14 - 7.1.0
2 years, 2 months, 815 days, 23 hours, 10 minutes, 04 seconds
Output for 7.0.6
3 years, 4 months, 1233 days, 22 hours, 29 minutes, 07 seconds
Output for 7.0.5
3 years, 2 months, 1185 days, 18 hours, 11 minutes, 05 seconds
Output for 7.0.4
3 years, 2 months, 1162 days, 6 hours, 22 minutes, 51 seconds
Output for 7.0.3
3 years, 2 months, 1170 days, 8 hours, 17 minutes, 24 seconds
Output for 7.0.2
3 years, 2 months, 1174 days, 14 hours, 11 minutes, 53 seconds
Output for 7.0.1
3 years, 2 months, 1175 days, 17 hours, 11 minutes, 33 seconds
Output for 7.0.0
3 years, 2 months, 1178 days, 18 hours, 57 minutes, 01 seconds
Output for 5.6.21
3 years, 3 months, 1215 days, 1 hour, 7 minutes, 23 seconds
Output for 5.6.20
3 years, 3 months, 1192 days, 17 hours, 14 minutes, 24 seconds
Output for 5.6.19
3 years, 2 months, 1159 days, 14 hours, 34 minutes, 07 seconds
Output for 5.6.18
3 years, 2 months, 1166 days, 23 hours, 40 minutes, 07 seconds
Output for 5.6.17
3 years, 2 months, 1171 days, 11 hours, 18 minutes, 31 seconds
Output for 5.6.16
3 years, 2 months, 1179 days, 19 hours, 46 minutes, 40 seconds
Output for 5.6.15
3 years, 2 months, 1180 days, 20 hours, 35 minutes, 32 seconds
Output for 5.6.14
3 years, 3 months, 1197 days, 2 hours, 19 minutes, 13 seconds
Output for 5.6.13
3 years, 3 months, 1198 days, 3 hours, 2 minutes, 29 seconds
Output for 5.6.12
3 years, 3 months, 1202 days, 17 hours, 59 minutes, 14 seconds
Output for 5.6.11
3 years, 3 months, 1206 days, 23 hours, 59 minutes, 00 seconds
Output for 5.6.10
3 years, 3 months, 1208 days, 2 hours, 4 minutes, 28 seconds
Output for 5.6.9
3 years, 3 months, 1210 days, 7 hours, 40 minutes, 12 seconds
Output for 5.6.8
3 years, 3 months, 1212 days, 15 hours, 56 minutes, 00 seconds
Output for 5.5.35
3 years, 4 months, 1235 days, 13 hours, 1 minute, 00 seconds
Output for 5.5.34
3 years, 3 months, 1193 days, 19 hours, 27 minutes, 56 seconds
Output for 5.5.33
3 years, 2 months, 1160 days, 17 hours, 42 minutes, 19 seconds
Output for 5.5.32
3 years, 2 months, 1169 days, 3 hours, 41 minutes, 41 seconds
Output for 5.5.31
3 years, 2 months, 1172 days, 14 hours, 33 minutes, 25 seconds
Output for 5.5.30
3 years, 2 months, 1183 days, 22 hours, 25 minutes, 46 seconds
Output for 5.5.29
3 years, 3 months, 1199 days, 17 hours, 14 minutes, 56 seconds
Output for 5.5.28
3 years, 3 months, 1203 days, 20 hours, 53 minutes, 08 seconds
Output for 5.5.27
3 years, 3 months, 1204 days, 22 hours, 26 minutes, 49 seconds
Output for 5.5.26
3 years, 3 months, 1209 days, 4 hours, 47 minutes, 30 seconds
Output for 5.5.25
3 years, 3 months, 1211 days, 12 hours, 17 minutes, 08 seconds
Output for 5.5.24
3 years, 4 months, 1236 days, 19 hours, 3 minutes, 49 seconds
Output for 5.4.45
3 years,1 month, 1140 days, 7 hours, 49 minutes, 33 seconds
Output for 5.4.42 - 5.4.44
3 years,1 month, 1140 days, 7 hours, 49 minutes, 34 seconds
Output for 5.4.41
3 years,1 month, 1140 days, 7 hours, 49 minutes, 35 seconds
Output for 5.4.38 - 5.4.40
3 years,1 month, 1140 days, 7 hours, 49 minutes, 36 seconds
Output for 5.4.36 - 5.4.37
3 years,1 month, 1140 days, 7 hours, 49 minutes, 37 seconds
Output for 5.4.34 - 5.4.35
3 years,1 month, 1140 days, 7 hours, 49 minutes, 38 seconds
Output for 5.3.29, 5.4.31 - 5.4.32
3 years,1 month, 1140 days, 7 hours, 49 minutes, 39 seconds
Output for 5.4.28 - 5.4.30
3 years,1 month, 1140 days, 7 hours, 49 minutes, 40 seconds
Output for 5.4.25 - 5.4.27
3 years,1 month, 1140 days, 7 hours, 49 minutes, 41 seconds
Output for 5.3.28, 5.4.22 - 5.4.24
3 years,1 month, 1140 days, 7 hours, 49 minutes, 42 seconds
Output for 5.4.19 - 5.4.21
3 years,1 month, 1140 days, 7 hours, 49 minutes, 43 seconds
Output for 5.3.26 - 5.3.27, 5.4.16 - 5.4.18
3 years,1 month, 1140 days, 7 hours, 49 minutes, 44 seconds
Output for 5.3.23 - 5.3.25, 5.4.12 - 5.4.15
3 years,1 month, 1140 days, 7 hours, 49 minutes, 45 seconds
Output for 5.3.19 - 5.3.22, 5.4.9 - 5.4.11
3 years,1 month, 1140 days, 7 hours, 49 minutes, 46 seconds
Output for 5.3.15 - 5.3.18, 5.4.5 - 5.4.8
3 years,1 month, 1140 days, 7 hours, 49 minutes, 47 seconds
Output for 5.3.11 - 5.3.14, 5.4.2 - 5.4.4
3 years,1 month, 1140 days, 7 hours, 49 minutes, 48 seconds
Output for 5.3.6 - 5.3.10, 5.4.0 - 5.4.1
3 years,1 month, 1140 days, 7 hours, 49 minutes, 49 seconds
Output for 5.3.2 - 5.3.5
3 years,1 month, 1140 days, 7 hours, 49 minutes, 50 seconds
Output for 5.3.0 - 5.3.1
3 years,1 month, 1140 days, 7 hours, 49 minutes, 51 seconds
Output for 5.2.0 - 5.2.17
Fatal error: Call to undefined method DateTime::diff() in /in/Me5IT on line 4
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/Me5IT 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/Me5IT 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/Me5IT on line 2