3v4l.org

run code in 300+ PHP versions simultaneously
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Turn off chat button if before/after hours</title> <meta name="description" content="untitled"> <meta name="author" content="Craig MacKinnon"> <!--[if lt IE 9]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script> function offMode() { jQuery(".initChat").addClass("offline"); jQuery(".initChat").removeAttr("onclick"); } </script> <style> * { margin:0; font: normal 12px sans-serif; } .initChat { background: url(http://i.snag.gy/DIPT4.jpg) no-repeat top left; display: block; height: 111px; width: 32px; position: fixed; top: 70%; z-index: 99999; } .initChat:hover { background-position: -34px 0px; cursor: pointer; } .initChat.offline { background-position: -68px 0px; cursor: context-menu; } </style> </head> <body> <?php // set timezone to Eastern Time date_default_timezone_set('America/New_York'); $storeSchedule = [ 'Sun' => ['closed'], 'Mon' => ['09:00 AM' => '05:00 PM'], 'Tue' => ['09:00 AM' => '05:00 PM'], 'Wed' => ['09:00 AM' => '05:00 PM'], 'Thu' => ['09:00 AM' => '05:00 PM'], 'Fri' => ['09:00 AM' => '05:00 PM'], 'Sat' => ['closed'] ]; // current or user supplied UNIX timestamp $timestamp = time(); // default status $status = 'open'; // 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 (($currentTime < $startTime) && ($currentTime > $endTime)) { $status = 'closed'; echo '<script>jQuery(function() { offMode(); });</script>'; break; } } echo "We are currently: $status"; echo "<br />"; echo "Server time: " . date('h:i A'); ?> <a class="initChat" onclick="window.open('https://admin.instantservice.com/links/7565/61447', 'custclient', 'width=612,height=380,scrollbars=0'); return false;"></a> </body> </html>

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.00.0050.01415.04
7.3.120.0070.01015.08
7.3.110.0070.01014.99
7.3.100.0070.00814.95
7.3.90.0090.00215.00
7.3.80.0060.01014.99
7.3.70.0050.00514.97
7.3.60.0070.00615.00
7.3.50.0060.00914.98
7.3.40.0030.00915.11
7.3.30.0050.00814.88
7.3.20.0040.01016.86
7.3.10.0090.00516.87
7.3.00.0080.00516.80
7.2.250.0080.01015.27
7.2.240.0050.01215.24
7.2.230.0060.00615.11
7.2.220.0080.00615.28
7.2.210.0050.00715.26
7.2.200.0080.00615.26
7.2.190.0050.01015.26
7.2.180.0070.00915.32
7.2.170.0040.01015.26
7.2.160.0090.00715.29
7.2.150.0080.00416.97
7.2.140.0100.00517.13
7.2.130.0030.00917.14
7.2.120.0050.00717.20
7.2.110.0020.01216.83
7.2.100.0070.00616.90
7.2.90.0070.00717.27
7.2.80.0070.00716.99
7.2.70.0020.01217.02
7.2.60.0080.00717.08
7.2.50.0050.01216.97
7.2.40.0030.01017.27
7.2.30.0050.01017.12
7.2.20.0050.01017.10
7.2.10.0060.00917.04
7.2.00.0050.00717.83
7.1.330.0050.01016.00
7.1.320.0030.00815.77
7.1.310.0030.00715.88
7.1.300.0070.00816.02
7.1.290.0040.01115.97
7.1.280.0100.00215.99
7.1.270.0060.00615.90
7.1.260.0050.00915.86
7.1.250.0050.00715.88
7.1.240.0080.00516.07
7.1.230.0030.00615.63
7.1.220.0060.00616.09
7.1.210.0040.00415.75
7.1.200.0070.00515.96
7.1.190.0000.00815.61
7.1.180.0000.01415.81
7.1.170.0040.01115.89
7.1.160.0090.00315.90
7.1.150.0000.01315.64
7.1.140.0100.00715.89
7.1.130.0030.01415.69
7.1.120.0030.00615.88
7.1.110.0060.00615.84
7.1.100.0000.01017.03
7.1.90.0110.00415.95
7.1.80.0000.01316.18
7.1.70.0060.00516.55
7.1.60.0100.00917.66
7.1.50.0080.00616.47
7.1.40.0060.00615.73
7.1.30.0120.00315.88
7.1.20.0040.00416.05
7.1.10.0060.00915.86
7.1.00.0050.04219.11
7.0.330.0040.00415.34
7.0.320.0060.00615.73
7.0.310.0040.00415.27
7.0.300.0110.00315.72
7.0.290.0030.00915.49
7.0.280.0040.00415.49
7.0.270.0100.00715.73
7.0.260.0040.00415.55
7.0.250.0030.00915.57
7.0.240.0000.01415.79
7.0.230.0100.00315.63
7.0.220.0000.01315.30
7.0.210.0000.00915.60
7.0.200.0050.00816.37
7.0.190.0000.01715.68
7.0.180.0060.00615.77
7.0.170.0100.00315.59
7.0.160.0030.00915.49
7.0.150.0080.00615.77
7.0.140.0030.04418.82
7.0.130.0040.00715.75
7.0.120.0070.00415.50
7.0.110.0060.00615.59
7.0.100.0040.04018.62
7.0.90.0040.04718.61
7.0.80.0030.03618.73
7.0.70.0030.04218.65
7.0.60.0150.03818.50
7.0.50.0060.04818.84
7.0.40.0050.04716.81
7.0.30.0070.04316.83
7.0.20.0080.04516.72
7.0.10.0050.03816.95
7.0.00.0070.04116.74
5.6.400.0040.01214.91
5.6.390.0030.01114.22
5.6.380.0080.00814.22
5.6.370.0040.00914.58
5.6.360.0040.00714.87
5.6.350.0100.00014.25
5.6.340.0000.01014.54
5.6.330.0070.01014.25
5.6.320.0050.00314.85
5.6.310.0000.01214.93
5.6.300.0050.00514.63
5.6.290.0000.01214.75
5.6.280.0020.04117.82
5.6.270.0030.01414.66
5.6.260.0100.00314.79
5.6.250.0080.02317.60
5.6.240.0050.04517.57
5.6.230.0030.04517.56
5.6.220.0080.03317.53
5.6.210.0070.03917.58
5.6.200.0080.04517.85
5.6.190.0070.04917.74
5.6.180.0040.03217.85
5.6.170.0030.04917.76
5.6.160.0060.04417.76
5.6.150.0050.03217.80
5.6.140.0030.02917.92
5.6.130.0060.04617.94
5.6.120.0140.02817.77
5.6.110.0080.05217.79
5.6.100.0050.02517.68
5.6.90.0050.02717.73
5.6.80.0080.04017.30
5.6.70.0020.03817.48
5.6.60.0100.04017.37
5.6.50.0030.04517.52
5.6.40.0030.04517.45
5.6.30.0040.04817.49
5.6.20.0070.04317.51
5.6.10.0100.03017.49
5.6.00.0040.02617.52
5.5.380.0050.04917.36
5.5.370.0040.03617.61
5.5.360.0110.01917.67
5.5.350.0060.03117.49
5.5.340.0090.03817.78
5.5.330.0150.02317.74
5.5.320.0070.03917.67
5.5.310.0120.03717.83
5.5.300.0020.04417.60
5.5.290.0030.03917.66
5.5.280.0080.02817.57
5.5.270.0080.04317.54
5.5.260.0050.04117.80
5.5.250.0080.04217.44
5.5.240.0050.04417.28
5.5.230.0070.04317.35
5.5.220.0030.03617.22
5.5.210.0040.02717.28
5.5.200.0070.04217.36
5.5.190.0080.02817.30
5.5.180.0100.02517.40
5.5.170.0070.00714.38
5.5.160.0080.02717.45
5.5.150.0040.03417.34
5.5.140.0050.02417.34
5.5.130.0030.04217.19
5.5.120.0110.03517.37
5.5.110.0070.02317.41
5.5.100.0070.02717.10
5.5.90.0080.02217.29
5.5.80.0060.03117.24
5.5.70.0050.02917.38
5.5.60.0050.02317.18
5.5.50.0000.02617.19
5.5.40.0080.02017.27
5.5.30.0050.02217.32
5.5.20.0040.02717.05
5.5.10.0070.02016.97
5.5.00.0040.02217.10
5.4.450.0050.04115.39
5.4.440.0070.04215.35
5.4.430.0050.04015.26
5.4.420.0080.03715.28
5.4.410.0020.03015.29
5.4.400.0050.04215.10
5.4.390.0070.03715.07
5.4.380.0080.03515.26
5.4.370.0050.03815.08
5.4.360.0060.02515.26
5.4.350.0050.04014.85
5.4.340.0100.04015.03
5.4.330.0080.00311.07
5.4.320.0070.04015.26
5.4.310.0020.04215.19
5.4.300.0070.03314.98
5.4.290.0050.02715.24
5.4.280.0060.02615.11
5.4.270.0100.02214.97
5.4.260.0030.02215.17
5.4.250.0020.02214.98
5.4.240.0070.02515.21
5.4.230.0020.02715.16
5.4.220.0070.02215.08
5.4.210.0070.02115.13
5.4.200.0050.02115.07
5.4.190.0030.02315.12
5.4.180.0050.02015.04
5.4.170.0000.02415.21
5.4.160.0020.02915.20
5.4.150.0040.02714.98
5.4.140.0060.02013.68
5.4.130.0030.02313.80
5.4.120.0020.02113.95
5.4.110.0040.01713.74
5.4.100.0020.03413.64
5.4.90.0020.02213.82
5.4.80.0020.02513.65
5.4.70.0030.02313.66
5.4.60.0030.02113.65
5.4.50.0020.02313.75
5.4.40.0010.02113.82
5.4.30.0020.02313.71
5.4.20.0020.02013.79
5.4.10.0050.02013.71
5.4.00.0020.02113.52
5.3.290.0050.03712.43
5.3.280.0030.02312.36
5.3.270.0000.02312.44
5.3.260.0090.01512.34
5.3.250.0030.02312.41
5.3.240.0050.02012.28
5.3.230.0050.02812.36
5.3.220.0050.02512.29
5.3.210.0020.02312.28
5.3.200.0020.02112.27
5.3.190.0050.01812.39
5.3.180.0060.01612.38
5.3.170.0040.02112.42
5.3.160.0050.02012.43
5.3.150.0080.01712.36
5.3.140.0020.02412.38
5.3.130.0020.02412.31
5.3.120.0010.02912.41
5.3.110.0040.01912.29
5.3.100.0050.04312.14
5.3.90.0030.02212.18
5.3.80.0060.01612.09
5.3.70.0020.02312.10
5.3.60.0050.02012.02
5.3.50.0050.02112.01
5.3.40.0000.02312.03
5.3.30.0020.02012.00
5.3.20.0030.01911.92
5.3.10.0050.01811.88
5.3.00.0020.02211.85
5.2.170.0130.01311.09
5.2.160.0000.03011.07
5.2.150.0000.03311.07
5.2.140.0030.03010.98
5.2.130.0000.02711.08
5.2.120.0070.02311.15
5.2.110.0100.02710.95
5.2.100.0000.03010.94
5.2.90.0000.03011.14
5.2.80.0030.03011.04
5.2.70.0000.03311.16
5.2.60.0000.06010.85
5.2.50.0070.02011.08
5.2.40.0070.03310.86
5.2.30.0000.04310.92
5.2.20.0030.02711.02
5.2.10.0070.05310.88
5.2.00.0000.03710.77
5.1.60.0070.0509.99
5.1.50.0000.0409.99
5.1.40.0030.0479.96
5.1.30.0070.04010.25
5.1.20.0000.03710.26
5.1.10.0070.04310.13
5.1.00.0000.03310.10
5.0.50.0000.0378.59
5.0.40.0030.0438.47
5.0.30.0030.0638.05
5.0.20.0030.0438.30
5.0.10.0000.0408.27
5.0.00.0030.0638.26
4.4.90.0030.0137.07
4.4.80.0030.0107.07
4.4.70.0000.0237.07
4.4.60.0030.0237.07
4.4.50.0000.0237.07
4.4.40.0000.0537.07
4.4.30.0030.0337.07
4.4.20.0030.0337.07
4.4.10.0000.0377.07
4.4.00.0030.0237.07
4.3.110.0030.0207.07
4.3.100.0000.0337.07
4.3.90.0000.0307.07
4.3.80.0030.0537.07
4.3.70.0000.0277.07
4.3.60.0030.0277.07
4.3.50.0000.0377.07
4.3.40.0000.0407.07
4.3.30.0000.0207.07
4.3.20.0000.0177.07
4.3.10.0030.0277.07
4.3.00.0030.0407.07

preferences:
35.84 ms | 401 KiB | 5 Q