3v4l.org

run code in 300+ PHP versions simultaneously
<?php date_default_timezone_set('UTC'); function get_pickup_time($str_cutoff_time, $int_flags = 0) { if (!preg_match('#^\d{2}:\d{2}$#', $str_cutoff_time)) { throw new \LogicException('Cutoff time must be expressed in 24 hour hh:mm format'); } $obj_now = new DateTime; $int_today = (int)$obj_now->format('N'); $int_add_days = 0; // cutoff time - 2 hr pickup window $obj_pickup_time = DateTime::createFromFormat('H:i', $str_cutoff_time)->sub(new DateInterval('PT2H')); // 2 hr lead time if ($obj_pickup_time->diff($obj_now)->h >= 2) { if (($int_today === 6 && !($int_flags & self::PICKUP_ALLOW_SATURDAY)) || ($int_today === 7 && !($int_flags & self::PICKUP_ALLOW_SUNDAY))) { // we don't deliver today $int_add_days = 8 - $int_today; } } else { if ($int_today === 5 && !($int_flags & self::PICKUP_ALLOW_SATURDAY)) { // today is friday and we don't do saturday $int_add_days = $int_flags & self::PICKUP_ALLOW_SUNDAY ? 2 : 3; } else if ($int_today === 6 && !($int_flags & self::PICKUP_ALLOW_SUNDAY)) { // today is saturday and we don't do sunday $int_add_days = 2; } else { $int_add_days = 1; } } if ($int_add_days > 0) { $obj_pickup_time->add(new DateInterval('P' . $int_add_days . 'D')); } return $obj_pickup_time; } var_dump((new DateTime)->format('Y-m-d H:i'), get_pickup_time('17:00')->format('Y-m-d H:i'));

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)
5.6.280.0100.06721.06
5.6.190.0030.07720.50
5.6.180.0330.07020.57
5.6.150.0070.06718.17
5.6.140.0070.08018.24
5.6.130.0100.03318.28
5.6.120.0100.05321.11
5.6.110.0070.08321.09
5.6.90.0070.07320.99
5.6.80.0170.06720.42
5.6.70.4500.03720.38
5.5.330.0070.06320.31
5.5.320.0370.03720.39
5.5.300.0000.04318.07
5.5.280.0070.04020.75
5.5.270.0130.07720.89
5.5.260.0070.06720.69
5.5.250.0070.04720.71
5.5.240.0270.07720.28
5.4.450.0870.05719.71
5.4.440.0900.05719.31
5.4.430.0800.05319.60
5.4.420.0230.06319.37
5.4.410.0170.04719.29
5.4.400.0370.05318.87
5.4.390.0470.07018.54
5.4.380.0430.05718.80
5.4.370.0230.05718.57
5.4.360.0500.07018.80
5.4.350.0470.06318.63
5.4.340.0090.04112.03
5.4.320.0110.05212.52
5.4.310.0240.06712.52
5.4.300.0120.05212.52
5.4.290.0200.07312.51
5.4.280.0120.08412.41
5.4.270.0230.07412.41
5.4.260.0090.06012.41
5.4.250.0190.08612.41
5.4.240.0110.04412.41
5.4.230.0120.04712.40
5.4.220.0080.03712.40
5.4.210.0080.03712.40
5.4.200.0080.03912.41
5.4.190.0090.05212.40
5.4.180.0060.05312.40
5.4.170.0110.06812.40
5.4.160.0110.05712.41
5.4.150.0100.04712.40
5.4.140.0090.04512.08
5.4.130.0080.04212.07
5.4.120.0060.05512.03
5.4.110.0070.05112.02
5.4.100.0090.07212.03
5.4.90.0160.05112.03
5.4.80.0110.07712.02
5.4.70.0150.07812.02
5.4.60.0730.08712.02
5.4.50.0100.04312.02
5.4.40.0150.05812.01
5.4.30.0090.06312.00
5.4.20.0090.05312.01
5.4.10.0100.04712.00
5.4.00.0140.06211.49
5.3.290.0090.05312.80
5.3.280.0100.06212.71
5.3.270.0140.04712.72
5.3.260.0100.05112.72
5.3.250.0160.06812.72
5.3.240.0080.03712.72
5.3.230.0080.04412.71
5.3.220.0210.09712.68
5.3.210.0140.04512.68
5.3.200.0120.05612.68
5.3.190.0060.04212.68
5.3.180.0060.04412.67
5.3.170.0050.04112.67
5.3.160.0110.03512.67
5.3.150.0070.06512.68
5.3.140.0060.04012.66
5.3.130.0070.04112.66
5.3.120.0100.03812.66
5.3.110.0080.04112.66
5.3.100.0080.04412.15
5.3.90.0060.03912.13
5.3.80.0120.03612.13
5.3.70.0120.05712.13
5.3.60.0100.05212.11
5.3.50.0090.05412.05
5.3.40.0120.04412.05
5.3.30.0100.04612.01
5.3.20.0080.05311.81
5.3.10.0090.06811.76
5.3.00.0070.04211.75
5.2.170.0040.0339.24
5.2.160.0060.0319.24
5.2.150.0060.0309.24
5.2.140.0060.0319.24
5.2.130.0050.0319.20
5.2.120.0070.0329.20
5.2.110.0060.0539.20
5.2.100.0090.0299.20
5.2.90.0060.0319.19
5.2.80.0030.0349.19
5.2.70.0040.0339.19
5.2.60.0070.0349.15
5.2.50.0070.0319.12
5.2.40.0080.0339.09
5.2.30.0080.0319.07
5.2.20.0090.0329.05
5.2.10.0130.0488.96
5.2.00.0050.0318.82
5.1.60.0060.0268.11
5.1.50.0060.0258.11
5.1.40.0040.0268.09
5.1.30.0040.0278.44
5.1.20.0060.0258.46
5.1.10.0060.0258.19
5.1.00.0060.0258.18
5.0.50.0060.0196.66
5.0.40.0020.0226.53
5.0.30.0030.0336.34
5.0.20.0050.0186.30
5.0.10.0040.0206.28
5.0.00.0020.0326.28
4.4.90.0030.0164.78
4.4.80.0030.0154.75
4.4.70.0040.0214.75
4.4.60.0050.0194.75
4.4.50.0070.0204.77
4.4.40.0040.0324.71
4.4.30.0050.0184.76
4.4.20.0040.0154.84
4.4.10.0040.0204.85
4.4.00.0040.0284.76
4.3.110.0060.0164.67
4.3.100.0060.0144.66
4.3.90.0040.0154.63
4.3.80.0050.0294.58
4.3.70.0050.0224.63
4.3.60.0070.0214.63
4.3.50.0110.0474.63
4.3.40.0120.0964.54
4.3.30.0000.0243.30
4.3.20.0020.0213.27
4.3.10.0040.0183.24
4.3.00.0030.0277.42

preferences:
137.52 ms | 1394 KiB | 7 Q