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' => 'closed', '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) { $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; } $now = strtotime('7:59pm'); $open = isOpen($now, $times); if ($open == 0) { echo "Is closed"; } else { echo "Is open. Will close in ".ceil($open/60)." minutes"; } ?>

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.0110.00318.55
8.3.50.0100.00722.13
8.3.40.0120.00318.93
8.3.30.0160.00319.20
8.3.20.0080.00020.35
8.3.10.0040.00421.57
8.3.00.0140.00719.91
8.2.180.0030.01717.00
8.2.170.0150.00622.96
8.2.160.0100.00320.45
8.2.150.0030.00524.18
8.2.140.0040.00424.66
8.2.130.0050.00326.16
8.2.120.0030.00621.06
8.2.110.0060.00322.20
8.2.100.0040.00818.03
8.2.90.0080.00019.37
8.2.80.0030.00517.97
8.2.70.0040.00417.88
8.2.60.0040.00818.05
8.2.50.0050.00518.07
8.2.40.0050.00519.95
8.2.30.0030.00718.51
8.2.20.0050.00318.04
8.2.10.0070.00018.20
8.2.00.0000.00918.11
8.1.280.0100.00725.92
8.1.270.0080.00024.09
8.1.260.0050.00326.35
8.1.250.0040.00428.09
8.1.240.0060.00322.16
8.1.230.0040.00719.09
8.1.220.0040.00417.79
8.1.210.0090.00018.77
8.1.200.0060.00317.36
8.1.190.0040.00417.60
8.1.180.0030.00518.10
8.1.170.0040.00418.82
8.1.160.0000.00822.00
8.1.150.0030.00519.06
8.1.140.0000.00817.73
8.1.130.0000.00817.98
8.1.120.0030.00517.69
8.1.110.0000.00717.78
8.1.100.0040.00417.63
8.1.90.0040.00417.73
8.1.80.0040.00417.75
8.1.70.0040.00417.66
8.1.60.0030.00517.69
8.1.50.0000.00817.66
8.1.40.0040.00417.72
8.1.30.0030.00517.70
8.1.20.0040.00417.90
8.1.10.0000.00817.79
8.1.00.0040.00417.68
8.0.300.0040.00418.77
8.0.290.0040.00416.88
8.0.280.0000.00718.52
8.0.270.0050.00217.33
8.0.260.0030.00317.47
8.0.250.0030.00317.27
8.0.240.0000.00817.14
8.0.230.0000.00717.21
8.0.220.0030.00317.18
8.0.210.0050.00317.23
8.0.200.0030.00317.24
8.0.190.0040.00417.30
8.0.180.0050.00217.11
8.0.170.0030.00617.14
8.0.160.0040.00417.16
8.0.150.0040.00417.18
8.0.140.0030.00717.20
8.0.130.0030.00313.47
8.0.120.0000.00817.16
8.0.110.0050.00317.18
8.0.100.0000.00717.03
8.0.90.0020.00517.06
8.0.80.0120.00317.09
8.0.70.0040.00417.04
8.0.60.0000.00716.97
8.0.50.0000.00817.04
8.0.30.0100.00817.42
8.0.20.0120.01117.40
8.0.10.0040.00417.16
8.0.00.0090.01016.88
7.4.330.0030.00315.22
7.4.320.0040.00416.64
7.4.300.0000.00616.78
7.4.290.0070.00016.80
7.4.280.0040.00416.71
7.4.270.0040.00416.71
7.4.260.0040.00416.70
7.4.250.0050.00216.69
7.4.240.0000.00716.77
7.4.230.0050.00316.77
7.4.220.0070.01116.73
7.4.210.0060.01316.92
7.4.200.0030.00316.57
7.4.160.0160.00016.76
7.4.150.0030.01417.40
7.4.140.0070.01017.86
7.4.130.0120.00516.76
7.4.120.0110.00916.90
7.4.110.0100.00716.72
7.4.100.0120.00616.60
7.4.90.0070.01116.63
7.4.80.0090.01219.39
7.4.70.0070.01016.75
7.4.60.0090.00916.80
7.4.50.0000.00616.82
7.4.40.0100.00616.85
7.4.30.0070.01016.87
7.4.00.0090.00715.33
7.3.330.0060.00013.45
7.3.320.0000.00513.61
7.3.310.0030.00416.57
7.3.300.0050.00216.50
7.3.290.0040.01416.57
7.3.280.0140.00316.59
7.3.270.0060.01217.40
7.3.260.0110.00616.82
7.3.250.0110.00816.73
7.3.240.0190.00316.72
7.3.230.0000.01816.75
7.3.210.0130.00316.79
7.3.200.0030.01319.39
7.3.190.0030.01516.95
7.3.180.0130.00316.63
7.3.170.0140.00616.89
7.3.160.0080.00816.87
7.3.120.0100.00715.17
7.3.110.0090.00815.20
7.3.100.0110.00015.23
7.3.90.0110.00415.11
7.3.80.0030.01015.06
7.3.70.0040.01115.18
7.3.60.0070.00715.20
7.3.50.0120.00314.83
7.3.40.0060.01014.80
7.3.30.0030.01014.86
7.3.20.0070.00416.85
7.3.10.0100.00516.76
7.3.00.0110.00516.95
7.2.330.0090.00917.00
7.2.320.0060.01216.97
7.2.310.0090.00916.71
7.2.300.0180.00417.16
7.2.290.0130.01016.87
7.2.250.0030.01015.28
7.2.240.0030.01515.31
7.2.230.0070.00715.30
7.2.220.0030.01515.05
7.2.210.0060.01015.46
7.2.200.0100.00715.41
7.2.190.0100.00715.04
7.2.180.0000.01415.36
7.2.170.0000.00915.03
7.2.130.0090.01016.91
7.2.120.0030.01517.14
7.2.110.0030.01317.14
7.2.100.0070.01017.18
7.2.90.0070.01017.16
7.2.80.0070.01017.02
7.2.70.0090.00917.09
7.2.60.0030.01616.88
7.2.50.0090.00617.06
7.2.40.0000.01917.21
7.2.30.0000.01717.16
7.2.20.0160.00316.89
7.2.10.0140.01017.20
7.2.00.0060.00618.51
7.1.330.0100.00316.08
7.1.320.0030.01415.90
7.1.310.0120.00416.00
7.1.300.0080.00516.20
7.1.290.0030.01015.87
7.1.280.0000.01115.93
7.1.270.0060.00915.89
7.1.260.0040.00816.03
7.1.250.0150.00015.94
7.1.100.0040.00818.30
7.1.70.0070.00017.52
7.1.60.0070.00317.49
7.1.50.0100.01317.27
7.1.00.0030.07722.37
7.0.200.0070.01016.80
7.0.140.0000.07021.96
7.0.90.0070.07321.73
7.0.80.0030.06021.78
7.0.70.0100.04021.71
7.0.60.0000.04721.81
7.0.50.0100.07722.04
7.0.40.0030.06020.05
7.0.30.0100.04020.17
7.0.20.0100.04020.17
7.0.10.0030.05020.09
7.0.00.0000.04720.11
5.6.280.0030.07321.15
5.6.240.0030.05320.70
5.6.230.0200.07020.61
5.6.220.0070.04320.60
5.6.210.0130.07320.66
5.6.200.0000.08321.11
5.6.190.0100.08021.10
5.6.180.0000.05021.05
5.6.170.0030.04721.02
5.6.160.0070.03721.04
5.6.150.0030.04321.13
5.6.140.0100.05321.02
5.6.130.0000.04320.99
5.6.120.0030.05021.06
5.6.110.0070.04320.95
5.6.100.0000.07720.94
5.6.90.0030.05320.98
5.6.80.0000.06720.46
5.6.70.0030.04020.56
5.6.60.0000.04320.34
5.6.50.0030.05720.41
5.6.40.0000.04020.39
5.6.30.0070.03020.46
5.6.20.0000.04320.40
5.6.10.0070.05720.42
5.6.00.0030.04320.53
5.5.380.0030.07720.53
5.5.370.0070.07020.39
5.5.360.0170.04020.38
5.5.350.0070.07720.47
5.5.340.0030.07020.91
5.5.330.0130.07320.89
5.5.320.0070.07720.91
5.5.310.0000.05020.78
5.5.300.0070.03320.93
5.5.290.0070.04020.90
5.5.280.0000.04320.90
5.5.270.0070.07720.80
5.5.260.0170.03020.84
5.5.250.0030.04020.73
5.5.240.0000.04720.30
5.5.230.0030.06020.20
5.5.220.0030.03720.32
5.5.210.0100.07320.16
5.5.200.0030.03320.14
5.5.190.0070.04020.10
5.5.180.0000.03720.28
5.5.160.0030.03320.29
5.5.150.0100.02720.26
5.5.140.0070.03720.25
5.5.130.0070.06020.23
5.5.120.0030.03320.16
5.5.110.0000.04020.27
5.5.100.0000.03720.11
5.5.90.0000.03320.18
5.5.80.0000.04020.06
5.5.70.0030.03720.16
5.5.60.0000.04020.11
5.5.50.0070.03720.02
5.5.40.0000.04720.17
5.5.30.0100.03019.98
5.5.20.0100.03020.15
5.5.10.0030.03720.12
5.5.00.0000.04320.03
5.4.450.0030.04719.51
5.4.440.0000.04319.37
5.4.430.0070.07019.46
5.4.420.0100.06319.37
5.4.410.0000.04719.24
5.4.400.0000.03719.16
5.4.390.0000.07719.04
5.4.380.0000.06019.18
5.4.370.0070.03019.13
5.4.360.0170.02319.02
5.4.350.0000.07019.18
5.4.340.0030.03719.04
5.4.320.0070.03018.88
5.4.310.0100.04318.90
5.4.300.0030.03719.04
5.4.290.0030.04719.14
5.4.280.0000.07019.04
5.4.270.0030.04319.20
5.4.260.0030.03719.20
5.4.250.0030.03019.04
5.4.240.0000.04319.22
5.4.230.0070.03318.98
5.4.220.0030.03719.08
5.4.210.0030.03719.08
5.4.200.0070.03318.99
5.4.190.0000.04019.08
5.4.180.0000.04019.14
5.4.170.0070.03719.17
5.4.160.0000.08019.10
5.4.150.0070.07319.11
5.4.140.0030.07316.39
5.4.130.0000.03016.46
5.4.120.0070.06316.48
5.4.110.0000.07016.39
5.4.100.0030.07316.48
5.4.90.0030.07316.52
5.4.80.0000.06016.45
5.4.70.0070.03316.53
5.4.60.0070.04716.30
5.4.50.0070.05016.45
5.4.40.0030.06316.45
5.4.30.0030.07016.40
5.4.20.0070.06716.46
5.4.10.0000.06016.42
5.4.00.0030.07315.86
5.3.290.0030.03714.66
5.3.280.0030.04014.55
5.3.270.0030.03714.61
5.3.260.0000.04014.65
5.3.250.0070.06714.69
5.3.240.0130.02714.71
5.3.230.0070.03714.65
5.3.220.0030.07314.70
5.3.210.0030.07014.64
5.3.200.0000.07714.56
5.3.190.0100.04014.51
5.3.180.0030.07714.55
5.3.170.0070.04014.64
5.3.160.0030.08014.58
5.3.150.0100.06714.72
5.3.140.0070.06014.67
5.3.130.0030.07714.59
5.3.120.0000.07014.60
5.3.110.0030.07314.55
5.3.100.0030.04014.01
5.3.90.0030.06014.10
5.3.80.0070.04014.10
5.3.70.0000.07714.14
5.3.60.0130.05714.04
5.3.50.0000.07713.86
5.3.40.0100.04013.89
5.3.30.0030.06013.91
5.3.20.0000.03313.77
5.3.10.0070.05713.74
5.3.00.0030.07313.72
5.2.170.0030.06711.28
5.2.160.0070.05311.08
5.2.150.0030.06011.16
5.2.140.0000.03711.07
5.2.130.0000.06011.21
5.2.120.0000.04710.98
5.2.110.0070.06011.17
5.2.100.0030.03711.25
5.2.90.0030.02311.03
5.2.80.0000.02711.21
5.2.70.0030.06711.15
5.2.60.0030.06711.18
5.2.50.0000.02711.03
5.2.40.0100.05310.90
5.2.30.0000.02711.11
5.2.20.0000.02711.11
5.2.10.0000.02710.80
5.2.00.0000.06310.84
5.1.60.0000.02010.27
5.1.50.0070.03710.27
5.1.40.0030.05310.27
5.1.30.0030.05010.50
5.1.20.0030.06010.29
5.1.10.0000.02710.27
5.1.00.0030.02710.27
5.0.50.0030.04310.27
5.0.40.0070.02710.27
5.0.30.0030.06310.27
5.0.20.0030.04310.27
5.0.10.0030.04310.27
5.0.00.0030.06010.27
4.4.90.0000.02010.27
4.4.80.0070.00710.27
4.4.70.0070.03310.27
4.4.60.0000.02010.27
4.4.50.0000.01710.27
4.4.40.0070.05010.27
4.4.30.0000.02310.27
4.4.20.0030.03310.27
4.4.10.0000.03710.27
4.4.00.0000.04710.27
4.3.110.0030.02310.27
4.3.100.0030.03710.27
4.3.90.0030.03010.27
4.3.80.0000.04010.27
4.3.70.0000.03710.27
4.3.60.0000.01710.27
4.3.50.0030.03010.27
4.3.40.0030.05310.27
4.3.30.0100.03010.27
4.3.20.0000.03710.27
4.3.10.0000.02710.27
4.3.00.0000.02710.27

preferences:
44.32 ms | 401 KiB | 5 Q