3v4l.org

run code in 300+ PHP versions simultaneously
<?php date_default_timezone_set('UTC'); $dates = array( '2014-01-20 20:00:00', '2014-01-21 20:00:00', '2014-01-22 14:00:00', '2014-01-22 20:00:00', '2014-01-23 20:00:00', '2014-01-25 20:00:00', '2014-01-26 20:00:00', '2014-01-31 20:00:00', '2014-02-01 20:00:00' ); function getDateRanges($dates) { $tsArr = array_map('strtotime', $dates); $ranges = array(); for ($i=0, $len = count($tsArr); $i < $len; $i++) { $rstart = $tsArr[$i]; $rend = $rstart; // determine the end of the range while (isset($tsArr[$i+1]) && ($tsArr[$i+1]-$tsArr[$i]) / (60*60) <= 24) { $rend = $tsArr[++$i]; } // create DateTime objects to work with dates $startDate = new DateTime('@'.$rstart); $endDate = new DateTime('@'.$rend); // get date start and last day of month $start = $startDate->format('j'); $lastDay = $startDate->format('t'); // if last day of month, append month name if ($start == $lastDay) $start = $startDate->format('jS M'); else $start = $startDate->format('jS'); // end date $end = $endDate->format('jS M ga'); $ranges[] = $start.'-'.$end; } return $ranges; } $arr = getDateRanges($dates); echo implode(', ', $arr);

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.70.0160.00616.61
8.3.60.0070.01418.52
8.3.50.0090.01121.02
8.3.40.0150.00018.92
8.3.30.0030.01020.20
8.3.20.0000.00820.21
8.3.10.0000.00821.88
8.3.00.0030.00622.40
8.2.180.0090.00916.63
8.2.170.0150.00322.96
8.2.160.0130.00022.13
8.2.150.0060.00324.18
8.2.140.0060.00324.66
8.2.130.0000.00726.16
8.2.120.0040.00420.90
8.2.110.0050.00519.11
8.2.100.0040.00818.03
8.2.90.0060.00319.30
8.2.80.0040.00419.25
8.2.70.0080.00017.75
8.2.60.0000.00817.93
8.2.50.0040.00418.07
8.2.40.0080.00019.88
8.2.30.0060.00619.52
8.2.20.0060.00317.92
8.2.10.0000.00918.01
8.2.00.0050.00318.06
8.1.280.0090.00625.92
8.1.270.0040.00423.99
8.1.260.0020.00526.35
8.1.250.0000.00828.09
8.1.240.0060.00620.82
8.1.230.0060.00620.96
8.1.220.0060.00318.77
8.1.210.0040.00419.04
8.1.200.0040.00717.48
8.1.190.0040.00417.51
8.1.180.0040.00418.10
8.1.170.0040.00418.77
8.1.160.0030.00618.86
8.1.150.0040.00418.71
8.1.140.0040.00417.60
8.1.130.0050.00317.74
8.1.120.0030.00417.55
8.1.110.0000.00817.51
8.1.100.0080.00017.64
8.1.90.0040.00417.62
8.1.80.0000.00717.59
8.1.70.0030.00317.63
8.1.60.0080.00017.70
8.1.50.0080.00017.63
8.1.40.0000.00717.61
8.1.30.0000.00817.62
8.1.20.0050.00317.75
8.1.10.0080.00017.63
8.1.00.0090.00017.57
8.0.300.0040.00419.88
8.0.290.0000.00817.18
8.0.280.0070.00018.48
8.0.270.0040.00417.20
8.0.260.0000.00716.90
8.0.250.0070.00017.13
8.0.240.0000.01016.99
8.0.230.0030.00417.11
8.0.220.0040.00416.95
8.0.210.0000.00717.03
8.0.200.0060.00017.08
8.0.190.0050.00317.14
8.0.180.0040.00417.06
8.0.170.0040.00417.02
8.0.160.0000.00717.02
8.0.150.0050.00216.94
8.0.140.0040.00416.90
8.0.130.0000.00613.52
8.0.120.0080.00016.97
8.0.110.0000.00817.05
8.0.100.0040.00417.12
8.0.90.0000.00716.94
8.0.80.0070.00717.04
8.0.70.0040.00416.95
8.0.60.0080.00017.08
8.0.50.0030.00517.02
8.0.30.0090.01017.31
8.0.20.0120.00817.40
8.0.10.0070.00017.00
8.0.00.0070.01216.98
7.4.330.0000.00615.00
7.4.320.0060.00016.66
7.4.300.0000.00816.61
7.4.290.0030.00316.70
7.4.280.0030.00316.73
7.4.270.0000.00716.52
7.4.260.0030.00316.64
7.4.250.0000.00916.66
7.4.240.0010.00616.65
7.4.230.0000.00716.59
7.4.220.0090.00916.73
7.4.210.0080.00816.64
7.4.200.0040.00416.64
7.4.190.0070.00016.50
7.4.160.0100.01416.69
7.4.150.0140.00417.40
7.4.140.0100.01117.86
7.4.130.0070.01116.78
7.4.120.0120.00616.69
7.4.110.0070.01116.38
7.4.100.0070.01016.66
7.4.90.0060.01116.77
7.4.80.0060.01219.39
7.4.70.0110.00616.76
7.4.60.0070.01116.66
7.4.50.0000.01016.59
7.4.40.0070.01122.77
7.4.30.0120.00916.53
7.4.00.0000.01515.13
7.3.330.0050.00013.37
7.3.320.0000.00513.53
7.3.310.0040.00416.59
7.3.300.0000.00716.36
7.3.290.0100.00316.55
7.3.280.0080.01016.52
7.3.270.0100.00617.40
7.3.260.0070.01016.61
7.3.250.0160.00516.53
7.3.240.0100.00716.46
7.3.230.0130.01016.52
7.3.210.0100.00716.70
7.3.200.0150.00319.39
7.3.190.0070.01016.70
7.3.180.0040.01216.72
7.3.170.0150.00016.48
7.3.160.0100.01116.38
7.3.120.0110.00715.22
7.2.330.0040.01316.78
7.2.320.0140.00516.58
7.2.310.0090.01316.93
7.2.300.0060.01016.74
7.2.290.0080.00816.67
7.1.100.0250.01816.36
7.1.70.0050.00317.40
7.1.60.0100.01419.32
7.1.50.0100.01317.16
7.1.00.0100.07022.51
7.0.200.0100.01016.70
7.0.140.0030.07321.96
7.0.100.0130.07319.96
7.0.90.0430.08019.95
7.0.80.0370.05719.90
7.0.70.0470.07019.89
7.0.60.0400.08020.00
7.0.50.0370.04720.32
7.0.40.0030.08720.14
7.0.30.0030.09019.95
7.0.20.0030.08320.11
7.0.10.0070.08020.17
7.0.00.0130.07320.06
5.6.280.0070.07021.04
5.6.250.0070.08320.65
5.6.240.0070.07720.71
5.6.230.0070.08320.61
5.6.220.0070.06720.69
5.6.210.0070.06020.68
5.6.200.0100.07720.96
5.6.190.0030.09021.12
5.6.180.0070.07720.97
5.6.170.0030.08321.05
5.6.160.0100.06020.93
5.6.150.0100.05321.09
5.6.140.0170.06321.15
5.6.130.0230.06321.09
5.6.120.0170.07320.95
5.6.110.0130.08021.09
5.6.100.0030.06321.09
5.6.90.0030.08721.04
5.6.80.0030.07020.38
5.6.70.0000.04720.34
5.6.60.0070.08320.39
5.6.50.0070.08020.35
5.6.40.0130.07720.41
5.6.30.0070.04720.32
5.6.20.0030.07720.54
5.6.10.0030.08320.32
5.6.00.0100.08020.31
5.5.380.0130.04320.38
5.5.370.0130.07320.39
5.5.360.0000.05720.36
5.5.350.0030.06320.40
5.5.340.0070.08020.94
5.5.330.0030.08320.93
5.5.320.0000.05720.90
5.5.310.0070.07020.94
5.5.300.0100.08020.79
5.5.290.0170.04720.80
5.5.280.0170.07720.81
5.5.270.0100.08020.91
5.5.260.0170.07720.64
5.5.250.0000.05720.63
5.5.240.0100.04720.32
5.5.230.0100.07720.04
5.5.220.0130.07320.19
5.5.210.0030.07720.26
5.5.200.0030.05720.30
5.5.190.0000.05020.25
5.5.180.0030.07020.16
5.5.160.0030.05720.25
5.5.150.0030.08020.19
5.5.140.0170.07020.27
5.5.130.0030.07720.12
5.5.120.0100.07320.22
5.5.110.0170.06720.23
5.5.100.0130.07020.17
5.5.90.0070.07320.17
5.5.80.0170.06320.10
5.5.70.0030.08720.05
5.5.60.0070.07320.16
5.5.50.0100.07719.95
5.5.40.0130.03720.11
5.5.30.0070.07020.11
5.5.20.0170.06320.15
5.5.10.0100.07319.99
5.5.00.0070.03719.98
5.4.450.0000.08719.56
5.4.440.0130.07319.36
5.4.430.0000.08319.53
5.4.420.0030.08719.39
5.4.410.0130.03719.43
5.4.400.0070.07319.04
5.4.390.0030.07019.09
5.4.380.0100.07319.09
5.4.370.0070.07719.13
5.4.360.0200.06019.17
5.4.350.0000.08019.16
5.4.340.0100.07018.88
5.4.320.0130.06019.03
5.4.310.0130.06719.16
5.4.300.0000.05019.05
5.4.290.0030.04318.85
5.4.280.0100.07719.23
5.4.270.0130.06719.07
5.4.260.0070.07319.14
5.4.250.0030.08319.16
5.4.240.0100.05319.04
5.4.230.0000.05719.16
5.4.220.0100.07318.88
5.4.210.0170.06719.05
5.4.200.0130.06719.02
5.4.190.0070.07719.08
5.4.180.0070.07318.89
5.4.170.0030.04719.22
5.4.160.0000.04018.85
5.4.150.0070.05019.21
5.4.140.0070.03316.43
5.4.130.0070.03316.33
5.4.120.0000.04016.43
5.4.110.0070.03316.34
5.4.100.0030.03716.51
5.4.90.0070.04316.36
5.4.80.0100.05716.34
5.4.70.0000.05016.52
5.4.60.0130.03016.45
5.4.50.0030.03716.45
5.4.40.0070.04716.50
5.4.30.0130.02316.46
5.4.20.0170.03716.41
5.4.10.0100.03016.32
5.4.00.0070.03315.70
5.3.290.0070.04714.70
5.3.280.0070.07314.68
5.3.270.0070.07314.55
5.3.260.0030.04014.74
5.3.250.0030.04014.64
5.3.240.0070.03314.71
5.3.230.0030.04314.61
5.3.220.0030.03314.57
5.3.210.0000.04314.63
5.3.200.0000.03714.70
5.3.190.0170.02714.55
5.3.180.0100.03714.64
5.3.170.0070.08014.60
5.3.160.0030.03314.61
5.3.150.0030.03714.61
5.3.140.0100.06014.59
5.3.130.0000.06014.58
5.3.120.0070.05714.70
5.3.110.0070.04714.62
5.3.100.0000.05314.03
5.3.90.0100.06314.01
5.3.80.0000.05314.01
5.3.70.0030.06314.14
5.3.60.0130.03013.94
5.3.50.0000.04314.03
5.3.40.0100.03013.95
5.3.30.0030.04313.84
5.3.20.0070.03313.82
5.3.10.0030.03313.67
5.3.00.0070.03313.66
5.2.170.0000.04011.27
5.2.160.0000.03011.25
5.2.150.0000.03311.25
5.2.140.0030.03311.07
5.2.130.0030.03011.03
5.2.120.0000.03011.03
5.2.110.0000.03311.21
5.2.100.0000.03711.18
5.2.90.0000.03011.23
5.2.80.0100.02311.17
5.2.70.0070.02711.22
5.2.60.0070.03011.09
5.2.50.0000.03010.93
5.2.40.0070.02310.90
5.2.30.0000.03011.01
5.2.20.0030.02710.84
5.2.10.0070.03310.98
5.2.00.0030.02310.76
5.1.60.0070.02010.02
5.1.50.0000.02710.02
5.1.40.0070.01710.06
5.1.30.0000.02710.27
5.1.20.0030.02310.48
5.1.10.0030.02310.12
5.1.00.0030.02310.17
5.0.50.0030.0179.94
5.0.40.0030.0309.94
5.0.30.0030.0309.94
5.0.20.0000.0209.94
5.0.10.0000.0409.94
5.0.00.0070.0379.94
4.4.90.0030.0139.94
4.4.80.0030.0139.94
4.4.70.0030.0139.94
4.4.60.0000.0309.94
4.4.50.0000.0209.94
4.4.40.0000.0239.94
4.4.30.0000.0179.94
4.4.20.0000.0179.94
4.4.10.0000.0309.94
4.4.00.0000.0379.94
4.3.110.0000.0179.94
4.3.100.0030.0139.94
4.3.90.0000.0139.94
4.3.80.0070.0479.94
4.3.70.0070.0309.94
4.3.60.0000.0239.94
4.3.50.0030.0339.94
4.3.40.0000.0539.94
4.3.30.0000.0339.94
4.3.20.0000.0379.94
4.3.10.0000.0379.94
4.3.00.0070.0309.94

preferences:
43.31 ms | 401 KiB | 5 Q