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); $interval = $start_time->diff($end_time); list($days, $hours, $minutes) = explode(':', $interval->format('%D:%H:%I')); $hours += ($days * 24); print_r(formatHour($hours, $minutes)); $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.0040.01118.55
8.3.50.0160.00522.04
8.3.40.0110.00719.39
8.3.30.0090.00619.42
8.3.20.0080.00020.59
8.3.10.0000.00822.14
8.3.00.0040.00422.56
8.2.180.0100.01016.63
8.2.170.0150.00322.96
8.2.160.0060.00921.02
8.2.150.0000.00824.18
8.2.140.0050.00324.66
8.2.130.0030.00526.16
8.2.120.0080.00019.61
8.2.110.0060.00322.32
8.2.100.0040.00818.28
8.2.90.0040.00419.65
8.2.80.0000.00818.28
8.2.70.0080.00018.13
8.2.60.0000.00818.18
8.2.50.0030.00618.07
8.2.40.0040.00418.41
8.2.30.0030.00618.37
8.2.20.0070.00018.06
8.2.10.0080.00019.75
8.2.00.0000.00818.09
8.1.280.0130.00625.92
8.1.270.0040.00422.34
8.1.260.0000.00826.35
8.1.250.0040.00428.09
8.1.240.0060.00324.08
8.1.230.0080.00419.09
8.1.220.0080.00018.04
8.1.210.0000.00818.77
8.1.200.0030.00717.72
8.1.190.0030.00617.78
8.1.180.0050.00318.10
8.1.170.0060.00318.90
8.1.160.0040.00422.19
8.1.150.0030.00618.89
8.1.140.0040.00417.86
8.1.130.0030.00517.94
8.1.120.0000.00817.75
8.1.110.0040.00417.80
8.1.100.0040.00417.82
8.1.90.0000.00717.81
8.1.80.0000.00717.82
8.1.70.0080.00017.75
8.1.60.0090.00317.93
8.1.50.0000.00817.84
8.1.40.0000.00817.85
8.1.30.0080.00017.98
8.1.20.0080.00017.95
8.1.10.0040.00417.77
8.1.00.0000.00817.76
8.0.300.0040.00418.77
8.0.290.0050.00217.38
8.0.280.0000.00718.55
8.0.270.0040.00417.58
8.0.260.0030.00317.25
8.0.250.0000.00717.39
8.0.240.0000.00717.37
8.0.230.0040.00417.34
8.0.220.0000.00817.31
8.0.210.0000.00717.19
8.0.200.0070.00017.26
8.0.190.0080.00017.34
8.0.180.0070.00017.29
8.0.170.0030.00517.39
8.0.160.0030.00517.23
8.0.150.0070.00017.27
8.0.140.0030.00617.28
8.0.130.0000.00613.71
8.0.120.0030.00617.27
8.0.110.0040.00417.26
8.0.100.0040.00417.37
8.0.90.0040.00417.33
8.0.80.0030.01217.28
8.0.70.0080.00017.18
8.0.60.0040.00417.29
8.0.50.0050.00217.37
8.0.30.0140.00517.44
8.0.20.0060.01217.68
8.0.10.0030.00517.50
8.0.00.0110.00717.05
7.4.330.0060.00015.00
7.4.320.0030.00316.75
7.4.300.0000.00616.69
7.4.290.0030.00316.74
7.4.280.0070.00016.93
7.4.270.0040.00416.91
7.4.260.0070.00016.87
7.4.250.0040.00416.83
7.4.240.0030.00416.85
7.4.230.0000.00716.69
7.4.220.0170.00716.89
7.4.210.0130.00616.90
7.4.200.0050.00316.69
7.4.190.0030.00316.85
7.4.160.0150.00316.76
7.4.150.0110.00917.40
7.4.140.0080.01017.86
7.4.130.0140.00416.99
7.4.120.0020.01916.81
7.4.110.0100.00716.73
7.4.100.0130.00716.85
7.4.90.0120.00616.87
7.4.80.0070.01419.39
7.4.70.0020.02016.98
7.4.60.0110.00816.79
7.4.50.0000.00816.77
7.4.40.0100.00422.77
7.4.30.0100.00716.84
7.4.10.0070.01015.38
7.4.00.0070.01015.21
7.3.330.0030.00313.65
7.3.320.0000.00613.73
7.3.310.0040.00416.65
7.3.300.0000.00716.53
7.3.290.0070.01016.67
7.3.280.0090.01016.61
7.3.270.0150.00417.40
7.3.260.0060.01216.71
7.3.250.0100.00816.98
7.3.240.0130.01016.70
7.3.230.0130.00416.76
7.3.210.0000.01717.06
7.3.200.0120.00919.39
7.3.190.0130.01016.75
7.3.180.0090.00616.78
7.3.170.0000.01616.76
7.3.160.0100.00716.75
7.3.130.0080.00615.39
7.3.120.0050.01015.20
7.3.110.0100.00714.98
7.3.100.0030.01014.89
7.3.90.0060.00315.23
7.3.80.0060.00915.12
7.3.70.0030.00615.20
7.3.60.0030.01014.86
7.3.50.0030.01214.89
7.3.40.0070.00715.19
7.3.30.0030.01315.22
7.3.20.0030.01016.71
7.3.10.0030.00816.86
7.3.00.0040.00716.71
7.2.330.0090.00917.08
7.2.320.0090.01117.14
7.2.310.0130.00417.05
7.2.300.0080.01516.80
7.2.290.0090.01317.00
7.2.260.0040.01515.39
7.2.250.0090.00915.32
7.2.240.0120.00315.43
7.2.230.0030.01315.50
7.2.220.0060.01215.54
7.2.210.0060.00615.33
7.2.200.0040.01215.31
7.2.190.0070.01015.48
7.2.180.0160.00315.38
7.2.170.0060.00915.39
7.2.160.0030.01415.52
7.2.150.0060.00817.12
7.2.140.0030.01317.29
7.2.130.0030.01317.15
7.2.120.0040.00917.07
7.2.110.0100.00617.20
7.2.100.0080.00816.97
7.2.90.0070.00717.07
7.2.80.0030.01117.20
7.2.70.0030.00817.15
7.2.60.0060.01017.13
7.2.50.0100.00517.13
7.2.40.0080.00517.11
7.2.30.0020.01317.05
7.2.20.0030.01017.21
7.2.10.0060.00617.16
7.2.00.0060.01317.14
7.1.330.0040.00815.86
7.1.320.0070.01015.96
7.1.310.0040.00716.27
7.1.300.0070.00715.97
7.1.290.0030.00615.92
7.1.280.0100.00316.01
7.1.270.0100.00315.81
7.1.260.0070.00715.99
7.1.250.0060.00615.76
7.1.240.0030.00715.87
7.1.230.0040.01115.85
7.1.220.0120.00415.68
7.1.210.0070.00716.16
7.1.200.0030.01015.79
7.1.190.0080.00416.07
7.1.180.0030.01416.02
7.1.170.0030.00615.89
7.1.160.0070.00715.84
7.1.150.0110.00315.98
7.1.140.0100.00016.05
7.1.130.0080.00416.18
7.1.120.0040.01115.66
7.1.110.0050.00516.13
7.1.100.0090.00015.93
7.1.90.0070.00716.02
7.1.80.0070.00715.91
7.1.70.0060.00616.60
7.1.60.0090.00917.98
7.1.50.0050.00716.57
7.1.40.0070.00715.81
7.1.30.0040.01115.92
7.1.20.0070.01016.04
7.1.10.0030.00915.80
7.1.00.0030.04119.18
7.0.330.0030.01015.41
7.0.320.0120.00315.52
7.0.310.0070.00715.54
7.0.300.0030.01015.44
7.0.290.0030.00715.71
7.0.280.0070.00715.34
7.0.270.0060.00915.50
7.0.260.0030.00915.58
7.0.250.0080.00515.60
7.0.240.0110.00415.38
7.0.230.0000.01015.74
7.0.220.0000.00815.70
7.0.210.0030.01315.58
7.0.200.0090.00616.30
7.0.190.0070.01015.59
7.0.180.0000.01115.77
7.0.170.0080.00415.50
7.0.160.0080.00415.69
7.0.150.0060.00915.34
7.0.140.0050.03518.82
7.0.130.0040.01115.65
7.0.120.0000.00815.49
7.0.110.0050.00315.70
7.0.100.0080.03917.81
7.0.90.0150.03217.96
7.0.80.0050.04117.79
7.0.70.0090.04217.83
7.0.60.0070.02217.82
7.0.50.0130.04618.06
7.0.40.0020.04816.87
7.0.30.0080.03116.87
7.0.20.0150.03516.95
7.0.10.0090.03716.84
7.0.00.0080.04216.90
5.6.400.0030.00614.57
5.6.390.0040.00914.64
5.6.380.0060.00614.22
5.6.370.0070.01014.76
5.6.360.0000.01414.78
5.6.350.0030.01314.94
5.6.340.0000.01414.89
5.6.330.0070.01115.00
5.6.320.0060.00314.71
5.6.310.0030.01314.90
5.6.300.0060.00914.91
5.6.290.0040.00714.78
5.6.280.0050.04017.83
5.6.270.0040.00714.89
5.6.260.0030.00814.64
5.6.250.0070.04717.63
5.6.240.0130.03317.61
5.6.230.0070.04217.54
5.6.220.0030.04517.73
5.6.210.0080.04117.54
5.6.200.0110.02517.86
5.6.190.0060.02617.81
5.6.180.0050.02317.88
5.6.170.0070.02517.92
5.6.160.0100.02717.81
5.6.150.0090.04417.83
5.6.140.0050.04717.99
5.6.130.0110.02417.88
5.6.120.0130.04017.88
5.6.110.0100.04017.67
5.6.100.0080.04317.90
5.6.90.0070.04617.88
5.6.80.0110.03817.44
5.6.70.0030.04417.44
5.6.60.0070.03717.55
5.6.50.0030.02717.33
5.6.40.0050.02617.48
5.6.30.0050.04617.61
5.6.20.0050.04417.42
5.6.10.0020.03117.44
5.6.00.0110.03517.35
5.5.380.0080.02417.56
5.5.370.0110.03817.68
5.5.360.0030.04317.38
5.5.350.0120.04017.58
5.5.340.0070.02517.60
5.5.330.0080.03617.64
5.5.320.0080.03517.63
5.5.310.0080.04317.75
5.5.300.0080.04617.62
5.5.290.0080.04217.84
5.5.280.0120.03717.70
5.5.270.0100.04517.71
5.5.260.0070.04517.52
5.5.250.0050.04317.60
5.5.240.0070.04017.19
5.5.230.0020.04617.14
5.5.220.0050.04317.32
5.5.210.0100.03817.40
5.5.200.0060.04317.34
5.5.190.0080.03117.42
5.5.180.0050.02817.25
5.5.170.0030.00914.80
5.5.160.0000.05217.38
5.5.150.0070.03717.26
5.5.140.0070.04017.39
5.5.130.0150.02817.22
5.5.120.0110.03617.24
5.5.110.0050.04117.42
5.5.100.0100.02617.42
5.5.90.0070.03517.19
5.5.80.0070.02717.41
5.5.70.0070.02517.08
5.5.60.0030.04717.33
5.5.50.0070.03617.08
5.5.40.0090.04017.18
5.5.30.0030.03517.38
5.5.20.0080.04017.36
5.5.10.0070.03917.45
5.5.00.0110.02017.36
5.4.450.0110.02815.27
5.4.440.0080.04115.41
5.4.430.0090.03015.53
5.4.420.0110.03615.39
5.4.410.0050.04415.14
5.4.400.0060.04215.27
5.4.390.0020.03215.12
5.4.380.0070.03315.00
5.4.370.0030.04314.99
5.4.360.0050.04215.28
5.4.350.0100.03515.25
5.4.340.0050.03915.17
5.4.330.0000.01211.06
5.4.320.0030.03815.31
5.4.310.0070.02215.34
5.4.300.0080.04015.26
5.4.290.0070.03715.32
5.4.280.0030.02715.31
5.4.270.0080.03815.36
5.4.260.0050.02315.32
5.4.250.0050.04015.25
5.4.240.0000.04415.32
5.4.230.0030.03215.15
5.4.220.0030.04414.98
5.4.210.0030.03415.17
5.4.200.0040.03715.15
5.4.190.0050.02215.07
5.4.180.0060.04015.10
5.4.170.0030.03015.10
5.4.160.0050.04215.22
5.4.150.0070.04015.33
5.4.140.0070.04013.85
5.4.130.0030.04513.91
5.4.120.0020.04313.88
5.4.110.0030.03913.89
5.4.100.0100.03213.76
5.4.90.0080.03813.82
5.4.80.0040.04413.86
5.4.70.0000.04113.85
5.4.60.0030.03913.73
5.4.50.0040.03513.83
5.4.40.0090.03314.09
5.4.30.0080.02313.82
5.4.20.0050.03413.98
5.4.10.0060.02313.96
5.4.00.0020.04413.57
5.3.290.0070.03712.90
5.3.280.0010.04112.89
5.3.270.0060.02312.72
5.3.260.0030.04512.97
5.3.250.0060.03112.86
5.3.240.0080.03312.69
5.3.230.0030.03712.81
5.3.220.0050.03512.54
5.3.210.0050.03812.57
5.3.200.0050.03812.59
5.3.190.0030.04312.76
5.3.180.0010.02612.80
5.3.170.0050.03512.73
5.3.160.0030.02812.78
5.3.150.0050.04112.68
5.3.140.0070.03812.80
5.3.130.0090.03912.71
5.3.120.0050.02412.82
5.3.110.0080.03812.76
5.3.100.0040.02212.54
5.3.90.0070.04012.58
5.3.80.0040.04212.33
5.3.70.0050.02712.46
5.3.60.0030.04112.32
5.3.50.0090.03912.46
5.3.40.0050.04412.32
5.3.30.0030.02612.37
5.3.20.0020.03012.24
5.3.10.0050.03512.07
5.3.00.0030.03312.22

preferences:
44.87 ms | 401 KiB | 5 Q