3v4l.org

run code in 300+ PHP versions simultaneously
<?php $times = array( 'mon' => '9:00 AM - 12:00 AM', 'tue' => '9:00 AM - 12:00 AM', 'wed' => '9:00 AM - 12:00 AM', 'thu' => '9:00 AM - 12:00 AM', 'fri' => '9:00 AM - 1:00 AM', 'sat' => '9:00 AM - 1:00 PM, 2:00 PM - 1:00 AM', 'sun' => 'closed' ); function compileHours($times, $timestamp) { $times = $times[strtolower(date('D',$timestamp))]; if(!strpos($times, '-')) return array(); $hours = explode(",", $times); $hours = array_map('explode', array_pad(array(),count($hours),'-'), $hours); $hours = array_map('array_map', array_pad(array(),count($hours),'strtotime'), $hours, array_pad(array(),count($hours),array_pad(array(),2,$timestamp))); end($hours); if ($hours[key($hours)][0] > $hours[key($hours)][1]) $hours[key($hours)][1] = strtotime('+1 day', $hours[key($hours)][1]); return $hours; } function isOpen($now, $times) { global $times; $open = 0; // time until closing in seconds or 0 if closed // merge opening hours of today and the day before $hours = array_merge(compileHours($times, strtotime('yesterday',$now)),compileHours($times, $now)); foreach ($hours as $h) { if ($now >= $h[0] and $now < $h[1]) { $open = $h[1] - $now; return $open; } } return $open; } echo isOpen('5:29 pm');

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.40.0120.00318.86
8.3.30.0030.01218.84
8.3.20.0000.00820.39
8.3.10.0040.00423.36
8.3.00.0060.00319.38
8.2.170.0120.00322.96
8.2.160.0040.01120.47
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0080.00017.50
8.2.110.0070.00322.21
8.2.100.0080.00417.72
8.2.90.0030.00517.63
8.2.80.0050.00317.97
8.2.70.0000.00917.91
8.2.60.0030.00618.09
8.2.50.0000.00818.10
8.2.40.0050.00321.11
8.2.30.0000.00720.52
8.2.20.0040.00417.58
8.2.10.0040.00418.14
8.2.00.0040.00417.98
8.1.270.0040.00423.84
8.1.260.0050.00326.35
8.1.250.0040.00428.09
8.1.240.0040.00423.74
8.1.230.0080.00318.98
8.1.220.0000.00917.74
8.1.210.0030.00518.77
8.1.200.0000.01217.35
8.1.190.0040.00417.35
8.1.180.0000.00818.10
8.1.170.0050.00318.50
8.1.160.0070.00021.97
8.1.150.0050.00218.95
8.1.140.0050.00319.49
8.1.130.0000.00717.57
8.1.120.0040.00417.33
8.1.110.0050.00317.48
8.1.100.0000.00817.26
8.1.90.0070.00017.47
8.1.80.0040.00417.32
8.1.70.0000.00717.44
8.1.60.0030.00617.49
8.1.50.0040.00417.53
8.1.40.0030.00517.45
8.1.30.0000.00817.67
8.1.20.0080.00017.57
8.1.10.0000.00717.63
8.1.00.0040.00417.53
8.0.300.0000.00719.80
8.0.290.0060.00316.63
8.0.280.0040.00418.35
8.0.270.0110.00217.27
8.0.260.0030.00317.22
8.0.250.0000.00716.82
8.0.240.0050.00316.92
8.0.230.0040.00416.90
8.0.220.0030.00416.81
8.0.210.0030.00516.85
8.0.200.0000.00616.99
8.0.190.0050.00317.02
8.0.180.0060.00316.96
8.0.170.0000.00816.80
8.0.160.0040.00416.92
8.0.150.0070.00016.84
8.0.140.0070.00016.85
8.0.130.0070.00013.35
8.0.120.0080.00016.77
8.0.110.0040.00416.88
8.0.100.0040.00416.88
8.0.90.0040.00416.98
8.0.80.0090.00616.91
8.0.70.0040.00416.75
8.0.60.0040.00416.95
8.0.50.0000.00716.97
8.0.30.0160.00117.27
8.0.20.0130.00717.40
8.0.10.0000.00716.92
8.0.00.0130.00716.80
7.4.330.0000.00515.08
7.4.320.0030.00316.57
7.4.300.0030.00316.59
7.4.290.0000.00716.45
7.4.280.0070.00016.61
7.4.270.0000.00616.48
7.4.260.0000.00716.53
7.4.250.0040.00416.58
7.4.240.0030.00316.57
7.4.230.0000.00616.44
7.4.220.0120.01216.43
7.4.210.0040.01116.64
7.4.200.0050.00316.36
7.4.160.0000.01416.57
7.4.150.0140.00417.40
7.4.140.0150.00617.86
7.4.130.0200.00416.46
7.4.120.0070.01016.56
7.4.110.0060.01116.53
7.4.100.0090.00916.55
7.4.90.0100.00716.47
7.4.80.0070.01019.39
7.4.70.0060.00916.54
7.4.60.0030.01516.61
7.4.50.0040.00416.37
7.4.40.0030.01316.46
7.4.30.0030.01316.64
7.4.00.0070.00715.17
7.3.330.0000.00513.25
7.3.320.0000.00513.14
7.3.310.0030.00616.41
7.3.300.0000.00716.21
7.3.290.0060.00816.29
7.3.280.0080.00916.31
7.3.270.0000.02017.40
7.3.260.0100.00616.42
7.3.240.0100.00816.26
7.3.230.0100.00716.60
7.3.210.0090.00616.54
7.3.200.0070.01016.33
7.3.190.0040.01216.61
7.3.180.0100.00716.54
7.3.170.0120.00316.43
7.3.160.0100.00716.35
7.2.330.0100.00716.43
7.2.320.0030.01816.40
7.2.310.0060.00916.37
7.2.300.0100.00616.61
7.2.290.0070.01016.59
7.2.60.0150.00016.74
7.2.00.0000.01819.30
7.1.200.0090.00315.62
7.1.100.0030.01017.85
7.1.70.0000.01016.82
7.1.60.0100.01419.13
7.1.50.0060.01216.82
7.1.00.0070.07022.36
7.0.200.0070.00315.13
7.0.100.0330.08719.95
7.0.90.0430.07719.91
7.0.80.0300.07719.93
7.0.70.0470.07719.93
7.0.60.0430.06019.90
7.0.50.0500.07720.22
7.0.40.0170.07320.13
7.0.30.0070.08720.12
7.0.20.0130.07020.11
7.0.10.0100.08020.14
7.0.00.0130.07020.14
5.6.280.0000.05020.79
5.6.250.0030.08020.55
5.6.240.0130.07020.54
5.6.230.0070.08020.75
5.6.220.0170.07720.60
5.6.210.0100.07720.62
5.6.200.0130.07721.08
5.6.190.0070.07321.19
5.6.180.0030.07721.07
5.6.170.0030.08720.97
5.6.160.0170.07321.03
5.6.150.0230.07021.13
5.6.140.0070.07021.18
5.6.130.0070.08721.08
5.6.120.0070.05321.03
5.6.110.0100.08320.92
5.6.100.0100.08021.04
5.6.90.0070.07021.07
5.6.80.0100.07020.43
5.6.70.0030.08320.43
5.6.60.0170.06020.40
5.6.50.0100.03320.48
5.6.40.0070.03720.30
5.6.30.0070.03720.47
5.6.20.0070.03720.38
5.6.10.0070.03720.39
5.6.00.0030.04020.49
5.5.380.0170.04020.36
5.5.370.0100.06020.39
5.5.360.0070.05320.45
5.5.350.0100.08320.40
5.5.340.0070.07720.86
5.5.330.0000.06020.78
5.5.320.0130.06720.93
5.5.310.0100.07020.78
5.5.300.0070.05020.83
5.5.290.0070.07320.88
5.5.280.0070.07020.75
5.5.270.0100.07720.80
5.5.260.0000.06020.76
5.5.250.0030.05020.66
5.5.240.0030.06720.24
5.5.230.0030.04720.30
5.5.220.0000.05020.12
5.5.210.0000.04320.15
5.5.200.0030.04320.17
5.5.190.0030.04020.22
5.5.180.0030.04320.25
5.5.160.0000.04320.26
5.5.150.0100.03319.99
5.5.140.0100.05720.29
5.5.130.0170.06020.14
5.5.120.0000.04320.00
5.5.110.0030.04720.21
5.5.100.0100.03720.20
5.5.90.0070.05720.18
5.5.80.0130.03320.16
5.5.70.0000.04319.95
5.5.60.0000.04320.16
5.5.50.0000.04720.02
5.5.40.0000.05320.07
5.5.30.0100.03720.10
5.5.20.0130.03320.07
5.5.10.0070.06320.05
5.5.00.0100.04720.05
5.4.450.0070.09019.18
5.4.440.0100.07719.42
5.4.430.0030.07319.35
5.4.420.0070.07019.35
5.4.410.0030.04719.36
5.4.400.0100.07018.86
5.4.390.0170.05018.85
5.4.380.0030.05319.06
5.4.370.0030.03719.16
5.4.360.0070.03719.14
5.4.350.0000.04719.20
5.4.340.0070.03319.13
5.4.320.0170.05018.88
5.4.310.0000.06018.85
5.4.300.0030.04019.02
5.4.290.0000.04018.84
5.4.280.0170.05718.87
5.4.270.0030.04719.10
5.4.260.0100.03719.14
5.4.250.0070.04319.02
5.4.240.0070.05019.04
5.4.230.0000.05319.09
5.4.220.0070.04319.02
5.4.210.0070.04319.04
5.4.200.0100.03719.03
5.4.190.0070.03719.12
5.4.180.0000.06719.12
5.4.170.0070.03019.13
5.4.160.0070.03019.09
5.4.150.0030.04019.11
5.4.140.0030.03716.25
5.4.130.0030.03016.55
5.4.120.0030.03716.50
5.4.110.0000.04016.45
5.4.100.0100.03016.39
5.4.90.0070.02716.42
5.4.80.0000.04316.38
5.4.70.0030.03316.42
5.4.60.0030.03716.50
5.4.50.0100.03016.36
5.4.40.0070.04716.35
5.4.30.0070.05016.36
5.4.20.0000.03316.50
5.4.10.0000.04316.47
5.4.00.0070.03715.86

preferences:
55.43 ms | 400 KiB | 5 Q