3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Workaround for PHP < 5.3.0 */ if(!function_exists('date_diff2')) { class DateInterval1 { public $y; public $m; public $d; public $h; public $i; public $s; public $invert; public $days; public function format($format) { $format = str_replace('%R%y', ($this->invert ? '-' : '+') . $this->y, $format); $format = str_replace('%R%m', ($this->invert ? '-' : '+') . $this->m, $format); $format = str_replace('%R%d', ($this->invert ? '-' : '+') . $this->d, $format); $format = str_replace('%R%h', ($this->invert ? '-' : '+') . $this->h, $format); $format = str_replace('%R%i', ($this->invert ? '-' : '+') . $this->i, $format); $format = str_replace('%R%s', ($this->invert ? '-' : '+') . $this->s, $format); $format = str_replace('%y', $this->y, $format); $format = str_replace('%m', $this->m, $format); $format = str_replace('%d', $this->d, $format); $format = str_replace('%h', $this->h, $format); $format = str_replace('%i', $this->i, $format); $format = str_replace('%s', $this->s, $format); return $format; } } function date_diff2(DateTime $date1, DateTime $date2) { $diff = new DateInterval1(); if($date1 > $date2) { $tmp = $date1; $date1 = $date2; $date2 = $tmp; $diff->invert = 1; } else { $diff->invert = 0; } $diff->y = ((int) $date2->format('Y')) - ((int) $date1->format('Y')); $diff->m = ((int) $date2->format('n')) - ((int) $date1->format('n')); if($diff->m < 0) { $diff->y -= 1; $diff->m = $diff->m + 12; } $diff->d = ((int) $date2->format('j')) - ((int) $date1->format('j')); if($diff->d < 0) { $diff->m -= 1; $diff->d = $diff->d + ((int) $date1->format('t')); } $diff->h = ((int) $date2->format('G')) - ((int) $date1->format('G')); if($diff->h < 0) { $diff->d -= 1; $diff->h = $diff->h + 24; } $diff->i = ((int) $date2->format('i')) - ((int) $date1->format('i')); if($diff->i < 0) { $diff->h -= 1; $diff->i = $diff->i + 60; } $diff->s = ((int) $date2->format('s')) - ((int) $date1->format('s')); if($diff->s < 0) { $diff->i -= 1; $diff->s = $diff->s + 60; } $start_ts = $date1->format('U'); $end_ts = $date2->format('U'); $days = $end_ts - $start_ts; $diff->days = round($days / 86400); if (($diff->h > 0 || $diff->i > 0 || $diff->s > 0)) $diff->days += ((bool) $diff->invert) ? 1 : -1; return $diff; } function formatHour($hours, $minutes) { // format info if ($minutes < 0) { // minutes < 0 // sub hours $hours -= floor(-$minutes / 60) + 1; // make minutes to objective $minutes += (floor(-$minutes / 60) + 1) * 60; } else { // minute > 0 // add hours $hours += floor($minutes / 60); // make minutes to < 60 $minutes -= floor($minutes / 60) * 60; } // make sure minutes patter in mm if ($minutes < 10) { $minutes = "0" . $minutes; } // return pattern hours:minutes return $hours . ':' . $minutes; } } // array(['2014-03-17 16:07:52', '2014-03-17 17:43:09'], '1:35'), $start_time = "2014-03-17 16:07:52"; $end_time = "2014-03-17 17:43:09"; $start_time = new DateTime($start_time); $end_time = new DateTime($end_time); echo '<br />'; $interval = date_diff2($start_time, $end_time); list($days, $hours, $minutes) = explode(':', $interval->format('%d:%h:%i')); $hours += ($days * 24); print_r(formatHour($hours, $minutes)); echo '<br />';

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0060.00918.55
8.3.50.0170.00022.16
8.3.40.0120.00919.09
8.3.30.0150.00019.34
8.3.20.0040.00420.34
8.3.10.0080.00022.08
8.3.00.0050.00222.40
8.2.180.0170.01017.00
8.2.170.0150.00022.96
8.2.160.0070.01120.99
8.2.150.0030.00524.18
8.2.140.0040.00424.66
8.2.130.0000.00826.16
8.2.120.0040.00419.48
8.2.110.0030.00622.33
8.2.100.0060.00618.16
8.2.90.0050.00318.28
8.2.80.0030.00618.25
8.2.70.0000.00818.00
8.2.60.0050.00318.04
8.2.50.0040.00418.07
8.2.40.0090.00018.59
8.2.30.0080.00018.35
8.2.20.0000.00818.20
8.2.10.0000.00818.09
8.2.00.0000.00818.21
8.1.280.0110.00725.92
8.1.270.0060.00322.45
8.1.260.0090.00026.35
8.1.250.0040.00428.09
8.1.240.0160.00620.97
8.1.230.0060.00621.15
8.1.220.0040.00418.04
8.1.210.0000.00818.86
8.1.200.0030.00617.73
8.1.190.0040.00417.89
8.1.180.0030.00618.10
8.1.170.0050.00318.93
8.1.160.0040.00422.09
8.1.150.0000.00818.90
8.1.140.0050.00317.90
8.1.130.0080.00018.05
8.1.120.0000.00717.78
8.1.110.0000.01017.82
8.1.100.0040.00417.83
8.1.90.0000.00817.70
8.1.80.0000.00717.83
8.1.70.0000.00717.66
8.1.60.0030.00617.81
8.1.50.0040.00417.75
8.1.40.0040.00417.80
8.1.30.0030.00517.87
8.1.20.0030.00517.86
8.1.10.0030.00617.84
8.1.00.0040.00417.83
8.0.300.0040.00420.11
8.0.290.0040.00417.30
8.0.280.0000.00818.71
8.0.270.0000.00717.47
8.0.260.0030.00317.25
8.0.250.0070.00017.37
8.0.240.0000.00717.36
8.0.230.0080.00017.30
8.0.220.0030.00317.30
8.0.210.0040.00417.29
8.0.200.0000.00717.23
8.0.190.0070.00017.36
8.0.180.0070.00017.27
8.0.170.0000.00817.36
8.0.160.0070.00017.11
8.0.150.0050.00217.14
8.0.140.0040.00417.28
8.0.130.0000.00613.66
8.0.120.0000.00817.25
8.0.110.0050.00517.30
8.0.100.0000.00817.17
8.0.90.0040.00417.15
8.0.80.0030.01417.35
8.0.70.0000.00817.33
8.0.60.0070.00017.19
8.0.50.0040.00417.18
8.0.30.0150.01117.56
8.0.20.0060.01317.50
8.0.10.0050.00217.38
8.0.00.0130.00617.28
7.4.330.0000.00515.27
7.4.320.0060.00016.77
7.4.300.0070.00016.85
7.4.290.0060.00316.93
7.4.280.0030.00316.79
7.4.270.0000.00716.79
7.4.260.0030.00316.86
7.4.250.0000.00716.84
7.4.240.0020.00516.77
7.4.230.0070.00016.68
7.4.220.0050.01316.90
7.4.210.0100.00816.83
7.4.200.0040.00416.64
7.4.190.0030.00516.75
7.4.160.0080.00816.93
7.4.150.0180.00017.40
7.4.140.0080.01017.86
7.4.130.0130.00816.84
7.4.120.0080.00816.81
7.4.110.0110.00716.76
7.4.100.0110.01016.96
7.4.90.0150.00316.93
7.4.80.0030.01619.39
7.4.70.0080.00916.80
7.4.60.0060.01016.86
7.4.50.0030.00616.83
7.4.40.0060.01222.77
7.4.30.0070.01016.95
7.4.00.0070.01014.96
7.3.330.0030.00313.50
7.3.320.0000.00513.52
7.3.310.0040.00416.68
7.3.300.0040.00416.51
7.3.290.0120.00316.71
7.3.280.0070.00916.66
7.3.270.0070.01017.40
7.3.260.0140.00316.88
7.3.250.0080.01016.74
7.3.240.0080.00916.87
7.3.230.0070.01016.84
7.3.210.0000.01916.68
7.3.200.0090.00919.39
7.3.190.0120.00616.59
7.3.180.0110.00516.85
7.3.170.0060.01616.74
7.3.160.0120.00616.82
7.3.120.0040.01215.23
7.2.330.0080.00817.10
7.2.320.0120.00617.14
7.2.310.0000.02117.16
7.2.300.0090.00916.91
7.2.290.0130.00417.17
7.2.60.0060.01017.25
7.2.50.0050.00817.19
7.1.200.0110.00315.88
7.1.70.0000.00717.06
7.1.60.0070.01719.82
7.1.50.0130.01317.16
7.1.00.0030.07722.54
7.0.200.0000.00717.03
7.0.140.0030.06721.97
7.0.100.0030.04320.13
7.0.90.0100.03320.00
7.0.80.0100.06020.02
7.0.70.0070.03720.08
7.0.60.0130.04020.07
7.0.50.0170.06020.43
7.0.40.0170.04020.10
7.0.30.0100.07320.08
7.0.20.0170.07720.18
7.0.10.0100.08020.05
7.0.00.0100.07320.10
5.6.280.0100.06320.90
5.6.250.0100.03320.76
5.6.240.0030.04020.73
5.6.230.0070.05320.61
5.6.220.0070.03720.77
5.6.210.0070.05320.59
5.6.200.0100.08021.09
5.6.190.0070.08021.17
5.6.180.0000.08721.06
5.6.170.0000.05021.11
5.6.160.0070.05021.08
5.6.150.0100.07721.14
5.6.140.0130.07320.98
5.6.130.0100.08321.08
5.6.120.0070.07721.08
5.6.110.0170.07321.08
5.6.100.0070.08321.04
5.6.90.0100.08321.05
5.6.80.0030.08720.37
5.6.70.0030.08320.38
5.6.60.0070.08320.52
5.6.50.0130.03720.47
5.6.40.0130.04020.43
5.6.30.0070.04720.45
5.6.20.0070.06720.33
5.6.10.0100.07720.49
5.6.00.0030.07720.52
5.5.380.0100.04020.53
5.5.370.0030.04320.49
5.5.360.0030.04020.41
5.5.350.0030.04320.44
5.5.340.0100.08320.67
5.5.330.0070.08320.92
5.5.320.0130.07320.93
5.5.310.0170.07720.77
5.5.300.0170.04020.82
5.5.290.0200.06720.86
5.5.280.0170.07720.81
5.5.270.0000.09020.91
5.5.260.0070.08020.80
5.5.250.0130.07720.68
5.5.240.0100.07320.29
5.5.230.0030.07020.35
5.5.220.0100.04320.35
5.5.210.0130.04320.26
5.5.200.0130.07020.17
5.5.190.0070.07720.15
5.5.180.0030.04320.28
5.5.160.0130.07320.29
5.5.150.0130.04020.02
5.5.140.0070.08020.18
5.5.130.0170.05320.29
5.5.120.0070.04720.27
5.5.110.0130.07720.24
5.5.100.0100.07020.19
5.5.90.0000.06720.11
5.5.80.0070.07320.11
5.5.70.0030.08320.20
5.5.60.0030.07720.07
5.5.50.0130.05319.93
5.5.40.0130.06720.09
5.5.30.0200.06720.15
5.5.20.0170.07020.10
5.5.10.0100.08020.00
5.5.00.0130.07320.04
5.4.450.0030.08319.27
5.4.440.0100.04019.27
5.4.430.0030.07319.55
5.4.420.0000.08719.24
5.4.410.0070.07319.15
5.4.400.0130.07319.10
5.4.390.0170.06019.11
5.4.380.0070.07318.96
5.4.370.0070.07718.96
5.4.360.0070.04319.01
5.4.350.0030.04019.09
5.4.340.0100.06019.22
5.4.320.0100.07719.29
5.4.310.0100.04719.18
5.4.300.0130.05719.02
5.4.290.0070.07718.94
5.4.280.0070.05319.04
5.4.270.0030.07318.90
5.4.260.0130.06718.93
5.4.250.0070.06319.19
5.4.240.0000.07718.96
5.4.230.0100.07318.91
5.4.220.0070.07019.18
5.4.210.0070.08019.12
5.4.200.0070.07319.29
5.4.190.0100.07319.09
5.4.180.0070.07019.08
5.4.170.0070.07319.21
5.4.160.0070.06719.08
5.4.150.0100.07319.18
5.4.140.0030.08316.48
5.4.130.0170.06016.51
5.4.120.0100.06016.57
5.4.110.0130.07016.56
5.4.100.0030.07016.46
5.4.90.0130.06316.63
5.4.80.0070.07716.52
5.4.70.0070.07716.55
5.4.60.0070.07716.50
5.4.50.0170.06716.54
5.4.40.0130.07016.52
5.4.30.0070.07316.52
5.4.20.0000.04716.43
5.4.10.0070.07316.52
5.4.00.0170.05316.02
5.3.290.0030.08014.76
5.3.280.0200.06314.64
5.3.270.0030.05714.70
5.3.260.0100.06014.65
5.3.250.0030.09014.71
5.3.240.0130.07014.68
5.3.230.0030.08014.65
5.3.220.0000.08014.66
5.3.210.0030.07314.64
5.3.200.0100.05714.74
5.3.190.0100.06714.62
5.3.180.0100.04714.61
5.3.170.0030.04714.72
5.3.160.0000.07714.75
5.3.150.0170.06014.71
5.3.140.0100.06714.74
5.3.130.0070.08314.73
5.3.120.0070.07714.73
5.3.110.0070.07014.64
5.3.100.0030.04314.22
5.3.90.0070.07314.09
5.3.80.0030.07714.07
5.3.70.0030.07714.08
5.3.60.0070.07714.18
5.3.50.0030.07314.06
5.3.40.0130.06314.02
5.3.30.0100.07014.09
5.3.20.0100.07013.77
5.3.10.0130.06713.69
5.3.00.0130.06313.74

preferences:
51.45 ms | 401 KiB | 5 Q