3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Based on the following business hours: * (Note : I setup the hours for each day if they carry-over) * everyday is open from 09:00 AM - 12:00 AM * Sun/Sat open extra from 12:00 AM - 01:00 AM */ $storeSchedule = [ 'Sun' => ['12:00 AM' => '01:00 AM'], 'Mon' => ['09:00 AM' => '12:00 AM'], 'Tue' => ['09:00 AM' => '12:00 AM'], 'Wed' => ['09:00 AM' => '12:00 AM'], 'Thu' => ['09:00 AM' => '12:00 AM'], 'Fri' => ['09:00 AM' => '12:00 AM'], 'Sat' => ['12:00 AM' => '01:00 AM'] ]; // current OR user supplied UNIX timestamp $timestamp = time(); // default status $status = 'closed'; // get current time object $currentTime = (new DateTime())->setTimestamp($timestamp); // loop through time ranges for current day foreach ($storeSchedule[date('D', $timestamp)] as $startTime => $endTime) { // create time objects from start/end times $startTime = DateTime::createFromFormat('h:i A', $startTime); $endTime = DateTime::createFromFormat('h:i A', $endTime); // check if current time is within a range if (($startTime < $currentTime) && ($currentTime < $endTime)) { $status = 'open'; break; } } echo "We are currently: $status";

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)
7.4.30.0130.00316.48
7.4.20.0050.01116.60
7.4.10.0090.00916.49
7.4.00.0180.00616.62
7.3.150.0040.01516.45
7.3.140.0110.00416.73
7.3.130.0090.01016.48
7.3.120.0110.00416.53
7.3.110.0070.01016.55
7.3.100.0090.01015.57
7.3.90.0130.00815.49
7.3.80.0090.01315.52
7.3.70.0120.00615.46
7.3.60.0150.00715.40
7.3.50.0120.00615.37
7.3.40.0110.00815.35
7.3.30.0100.00815.23
7.3.20.0190.00915.34
7.3.10.0230.00915.23
7.3.00.0210.00915.34
7.2.280.0100.00916.63
7.2.270.0150.00616.88
7.2.260.0100.01316.67
7.2.250.0120.00816.81
7.2.240.0100.00916.71
7.2.230.0170.00615.60
7.2.220.0100.01015.84
7.2.210.0140.00615.63
7.2.200.0100.00915.57
7.2.190.0090.01315.68
7.2.180.0140.00515.55
7.2.170.0120.00915.67
7.2.160.0070.01115.49
7.2.150.0260.00615.64
7.2.140.0230.00915.45
7.2.130.0240.00915.61
7.2.120.0300.00915.41
7.2.110.0240.00815.33
7.2.100.0310.00915.31
7.2.90.0220.01015.35
7.2.80.0250.00715.34
7.2.70.0250.00915.50
7.2.60.0200.00915.62
7.2.50.0230.01115.40
7.2.40.0270.00815.43
7.2.30.0270.00915.50
7.2.20.0380.00815.41
7.2.10.0230.00815.48
7.2.00.0220.01116.29
7.1.330.0120.01715.69
7.1.320.0140.01014.58
7.1.310.0130.01514.70
7.1.300.0170.00614.61
7.1.290.0190.00714.47
7.1.280.0200.00714.58
7.1.270.0260.00814.48
7.1.260.0280.00514.55
7.1.250.0230.00714.54
7.1.240.0340.00914.32
7.1.230.0330.00514.26
7.1.220.0310.00814.31
7.1.210.0470.00914.30
7.1.200.0270.00714.49
7.1.190.0270.00814.29
7.1.180.0250.01014.26
7.1.170.0290.00914.34
7.1.160.0270.00814.26
7.1.150.0330.00714.20
7.1.140.0320.00714.28
7.1.130.0390.01114.37
7.1.120.0370.01014.68
7.1.110.0350.00714.69
7.1.100.0250.01015.10
7.1.90.0240.01015.06
7.1.80.0240.00715.03
7.1.70.0220.00615.09
7.1.60.0210.01019.14
7.1.50.0260.01119.05
7.1.40.0250.01018.95
7.1.30.0240.00818.86
7.1.20.0250.01218.90
7.1.10.0270.00414.93
7.1.00.0180.00814.94
7.0.330.0240.00913.99
7.0.320.0340.00713.95
7.0.310.0270.00913.89
7.0.300.0500.00814.06
7.0.290.0310.00713.93
7.0.280.0280.00913.99
7.0.270.0460.00913.97
7.0.260.0280.01014.38
7.0.250.0290.00714.44
7.0.240.0270.01014.39
7.0.230.0250.00914.78
7.0.220.0220.00914.78
7.0.210.0260.00814.48
7.0.200.0210.00914.87
7.0.190.0200.00814.78
7.0.180.0220.00714.62
7.0.170.0210.00914.57
7.0.160.0200.00714.61
7.0.150.0210.01014.57
7.0.140.0180.00714.65
7.0.130.0160.00914.68
7.0.120.0260.00714.60
7.0.110.0310.01014.67
7.0.100.0210.00814.64
7.0.90.0180.00914.58
7.0.80.0190.00914.59
7.0.70.0220.00514.60
7.0.60.0200.00814.55
7.0.50.0220.00914.66
7.0.40.0210.00914.51
7.0.30.0180.00814.52
7.0.20.0230.01014.41
7.0.10.0190.00914.46
7.0.00.0210.01014.48
5.6.400.0140.00814.89
5.6.390.0170.01115.02
5.6.380.0150.00814.69
5.6.370.0160.00914.63
5.6.360.0140.00914.74
5.6.350.0150.00914.80
5.6.340.0140.00914.77
5.6.330.0150.00814.73
5.6.320.0150.00814.79
5.6.310.0140.00914.79
5.6.300.0120.02516.75
5.6.290.0120.02416.74
5.6.280.0080.02816.76
5.6.270.0140.02216.72
5.6.260.0120.02716.79
5.6.250.0110.02316.83
5.6.240.0110.02616.67
5.6.230.0110.02516.78
5.6.220.0120.02316.77
5.6.210.0130.02216.77
5.6.200.0130.02616.76
5.6.190.0110.02416.72
5.6.180.0100.02716.73
5.6.170.0120.02316.78
5.6.160.0110.02416.63
5.6.150.0120.02416.71
5.6.140.0120.02316.76
5.6.130.0120.02316.78
5.6.120.0120.02216.78
5.6.110.0100.02516.76
5.6.100.0130.02216.68
5.6.90.0090.02416.74
5.6.80.0130.02316.52
5.6.70.0110.02216.39
5.6.60.0150.02216.50
5.6.50.0130.02116.49
5.6.40.0100.02516.61
5.6.30.0120.02416.54
5.6.20.0080.02716.43
5.6.10.0120.02416.51
5.6.00.0160.02216.48
5.5.380.0100.02314.95
5.5.370.0140.01914.89
5.5.360.0100.02415.01
5.5.350.0100.02214.91
5.5.340.0100.02215.06
5.5.330.0100.02515.07
5.5.320.0100.02515.01
5.5.310.0110.02115.00
5.5.300.0120.02114.99
5.5.290.0120.02015.09
5.5.280.0100.02315.11
5.5.270.0110.03315.10
5.5.260.0100.02615.09
5.5.250.0110.02214.98
5.5.240.0120.02014.81
5.5.230.0100.02614.81
5.5.220.0090.02314.83
5.5.210.0110.02014.80
5.5.200.0090.02214.84
5.5.190.0080.02514.74
5.5.180.0140.01814.88
5.5.170.0140.00814.70
5.5.160.0120.02014.82
5.5.150.0110.02414.79
5.5.140.0090.02214.83
5.5.130.0110.02014.75
5.5.120.0110.02114.85
5.5.110.0110.02114.83
5.5.100.0120.02014.85
5.5.90.0100.02114.71
5.5.80.0090.02214.82
5.5.70.0070.02514.75
5.5.60.0120.02314.81
5.5.50.0120.02314.75
5.5.40.0120.02214.85
5.5.30.0110.01914.74
5.5.20.0100.02214.75
5.5.10.0130.02114.72
5.5.00.0110.02214.75
5.4.450.0100.02314.12
5.4.440.0120.02014.09
5.4.430.0120.02014.09
5.4.420.0090.02014.08
5.4.410.0090.02014.01
5.4.400.0120.01613.97
5.4.390.0110.01813.97
5.4.380.0090.02213.88
5.4.370.0110.02113.92
5.4.360.0100.02613.93
5.4.350.0080.02013.90
5.4.340.0100.01913.97
5.4.330.0090.00711.33
5.4.320.0110.02013.92
5.4.310.0110.01913.96
5.4.300.0080.02013.88
5.4.290.0090.02013.91
5.4.280.0110.01913.87
5.4.270.0100.01913.85
5.4.260.0110.01913.85
5.4.250.0080.02113.95
5.4.240.0120.01913.87
5.4.230.0060.02113.94
5.4.220.0090.02013.85
5.4.210.0090.02214.00
5.4.200.0110.01913.81
5.4.190.0080.01913.96
5.4.180.0080.02113.87
5.4.170.0090.02213.88
5.4.160.0100.02013.87
5.4.150.0100.02113.88
5.4.140.0120.01813.14
5.4.130.0080.02213.08
5.4.120.0090.01913.16
5.4.110.0100.01813.14
5.4.100.0110.01613.08
5.4.90.0090.01813.19
5.4.80.0090.01713.16
5.4.70.0090.01913.17
5.4.60.0110.02113.07
5.4.50.0110.01613.04
5.4.40.0100.01813.11
5.4.30.0100.01813.08
5.4.20.0090.01813.08
5.4.10.0080.02013.15
5.4.00.0070.02412.87
5.3.290.0060.02512.07
5.3.280.0080.01912.04
5.3.270.0100.01912.06
5.3.260.0090.02012.07
5.3.250.0080.02112.05
5.3.240.0120.02211.98
5.3.230.0110.01812.05
5.3.220.0090.02012.00
5.3.210.0120.02012.06
5.3.200.0080.02111.97
5.3.190.0080.01912.09
5.3.180.0090.01812.08
5.3.170.0060.02312.13
5.3.160.0110.01912.11
5.3.150.0060.02112.12
5.3.140.0090.01912.07
5.3.130.0070.02112.14
5.3.120.0080.02312.10
5.3.110.0060.02412.07
5.3.100.0090.02111.95
5.3.90.0080.02111.97
5.3.80.0100.01811.94
5.3.70.0090.01911.87
5.3.60.0090.02111.90
5.3.50.0090.02011.85
5.3.40.0100.01811.92
5.3.30.0120.01811.86
5.3.20.0100.01911.83
5.3.10.0080.02011.71
5.3.00.0110.01711.74

preferences:
50.31 ms | 401 KiB | 5 Q