3v4l.org

run code in 300+ PHP versions simultaneously
<?php function calculate_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_now->diff($obj_pickup_time)->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; } echo calculate_pickup_time('18:00')->format('Y-m-d H:i:s');;

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.210.0070.07720.55
5.6.200.0030.06318.14
5.6.190.0130.08020.77
5.6.180.0270.03720.46
5.6.160.0100.05020.39
5.6.150.0000.07718.13
5.6.140.0030.04018.27
5.6.120.0200.06321.00
5.6.110.0100.08021.16
5.6.100.0070.08721.04
5.6.90.0170.06021.14
5.5.350.1370.05720.42
5.5.340.0070.07717.96
5.5.330.0100.04320.27
5.5.320.0530.06020.52
5.5.310.0130.04720.23
5.5.290.0070.07717.94
5.5.280.0100.07020.70
5.5.260.0100.07720.89
5.5.240.0230.06320.21
5.4.450.0200.06019.09
5.4.440.0230.05719.59
5.4.430.0330.06719.48
5.4.420.0170.06719.56
5.4.410.0100.06019.42
5.4.400.0070.05719.22
5.4.390.0200.05019.04
5.4.380.0130.05719.14
5.4.370.0100.07719.24
5.4.360.0100.05319.06
5.4.350.0100.04412.03
5.4.340.0060.04112.03
5.4.320.0080.03712.52
5.4.310.0110.03612.51
5.4.300.0080.03812.51
5.4.290.0080.03612.52
5.4.280.0120.04812.41
5.4.270.0060.04512.41
5.4.260.0040.04712.41
5.4.250.0080.03712.41
5.4.240.0060.04412.41
5.4.230.0090.03812.40
5.4.220.0050.05112.40
5.4.210.0100.04412.41
5.4.200.0090.05812.40
5.4.190.0100.06612.40
5.4.180.0060.03912.40
5.4.170.0050.04312.41
5.4.160.0060.03912.41
5.4.150.0040.03912.40
5.4.140.0050.04312.09
5.4.130.0100.03612.07
5.4.120.0060.04412.04
5.4.110.0070.04012.03
5.4.100.0100.04612.02
5.4.90.0080.05212.03
5.4.80.0060.05212.03
5.4.70.0070.04812.03
5.4.60.0100.04512.02
5.4.50.0100.04712.02
5.4.40.0090.04612.01
5.4.30.0140.05312.00
5.4.20.0120.05512.01
5.4.10.0120.05612.00
5.4.00.0050.05711.50
5.3.290.0170.06512.80
5.3.280.0110.06712.71
5.3.270.0100.08012.73
5.3.260.0230.10812.72
5.3.250.0180.11012.72
5.3.240.0150.09712.72
5.3.230.0120.05312.71
5.3.220.0100.04712.69
5.3.210.0080.05812.68
5.3.200.0110.04412.68
5.3.190.0080.04012.68
5.3.180.0070.03912.68
5.3.170.0080.04112.68
5.3.160.0070.04812.68
5.3.150.0100.03812.68
5.3.140.0100.03412.66
5.3.130.0060.04212.66
5.3.120.0060.04312.66
5.3.110.0080.04712.66
5.3.100.0290.09612.16
5.3.90.0130.06112.14
5.3.80.0150.04612.13
5.3.70.0060.03912.12
5.3.60.0080.03712.11
5.3.50.0080.04012.05
5.3.40.0080.05212.06
5.3.30.0070.03712.02
5.3.20.0070.03811.80
5.3.10.0080.03811.77
5.3.00.0060.04311.75
5.2.170.0050.0339.25
5.2.160.0040.0319.25
5.2.150.0050.0319.26
5.2.140.0040.0339.25
5.2.130.0040.0349.21
5.2.120.0050.0319.21
5.2.110.0080.0529.22
5.2.100.0060.0359.21
5.2.90.0080.0339.21
5.2.80.0100.0529.20
5.2.70.0120.0989.20
5.2.60.0130.0639.16
5.2.50.0100.0509.13
5.2.40.0060.0339.11
5.2.30.0100.0359.09
5.2.20.0110.0569.07
5.2.10.0070.0458.96
5.2.00.0060.0318.83
5.1.60.0040.0308.12
5.1.50.0050.0338.11
5.1.40.0050.0288.09
5.1.30.0060.0408.44
5.1.20.0020.0348.46
5.1.10.0070.0268.19
5.1.00.0050.0288.19
5.0.50.0070.0186.66
5.0.40.0050.0196.53
5.0.30.0020.0336.33
5.0.20.0060.0196.30
5.0.10.0050.0246.28
5.0.00.0050.0386.28
4.4.90.0030.0224.78
4.4.80.0050.0204.75
4.4.70.0040.0174.75
4.4.60.0040.0174.76
4.4.50.0020.0204.77
4.4.40.0010.0284.70
4.4.30.0050.0204.76
4.4.20.0030.0234.84
4.4.10.0060.0204.85
4.4.00.0030.0334.76
4.3.110.0030.0224.67
4.3.100.0040.0154.66
4.3.90.0050.0134.64
4.3.80.0030.0304.58
4.3.70.0080.0304.63
4.3.60.0040.0144.62
4.3.50.0040.0154.63
4.3.40.0060.0234.54
4.3.30.0010.0173.30
4.3.20.0010.0173.28
4.3.10.0030.0153.24
4.3.00.0070.0206.82

preferences:
138.04 ms | 1386 KiB | 7 Q