3v4l.org

run code in 300+ PHP versions simultaneously
<?php //function checkDeliveryPeriod(bool $isGas = false) //{ // $startDate = new DateTime('2020-08-01 00:00:00'); // $endDate = new DateTime('2024-02-16'); // // initial // $originReadAt = new DateTime('2024-02-17 00:00:00'); // $readAt = clone $originReadAt; // if ($isGas && $endDate !== null && $readAt > $endDate) { // //Gas day case: gas day ends at 6:00 next day // $readAt->subHours(6); // } // $readAt->setTime(0, 0, 0); // // // assure contract start date // if ($startDate == null) { // return false; // } // //special case when the start and end dates of the contract are the same // $startEndOnSameDay = ( // ($originReadAt->format('H:i') == '00:00') // && ($endDate === $startDate) // ); // // final check // return ( // $readAt >= $startDate // && ( // $endDate === null // || ($endDate !== null && $readAt <= $endDate) // ) // ) || $startEndOnSameDay; //} // //var_dump(checkDeliveryPeriod()); function determineNewRunAt(\DateTimeInterface $createdAt): DateTime { $nextRunAt = new DateTime(); $oneMonth = (clone $createdAt)->modify('1month'); $diff = $nextRunAt->diff($createdAt); var_dump($diff->days, $diff->h); // time out after one month after creation if ($nextRunAt >= $oneMonth) { throw new \Exception('Waiting time expired'); } // run the action once a day, if it was not finished within 1 day after creation if ($diff->days >= 1) { return $nextRunAt->modify('1day'); } return $diff->h === 0 ? $nextRunAt->modify('5minute') // run the action every 5 minutes within the first hour after creation : $nextRunAt->modify('1hour'); // run the action every hour for one day after creation } $nextRunAt = determineNewRunAt(new DateTime('2024-04-10 07:15')); var_dump($nextRunAt->format('Y-m-d h:i:s')); $nextRunAt = determineNewRunAt(new DateTime('2024-04-10 06:15')); var_dump($nextRunAt->format('Y-m-d h:i:s')); $nextRunAt = determineNewRunAt(new DateTime('2024-04-09 06:15')); var_dump($nextRunAt->format('Y-m-d h:i:s')); try { $nextRunAt = determineNewRunAt(new DateTime('2024-03-09 06:15')); } catch (\Throwable $e) { var_dump($e->getMessage()); }

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.5.10.0150.00416.94
8.5.00.0130.01020.23
8.4.160.0170.00523.87
8.4.150.0010.00114.05
8.4.140.0090.01117.92
8.4.130.0090.00417.87
8.4.120.0070.00320.40
8.4.110.0090.01118.95
8.4.100.0100.00718.28
8.4.90.0170.00620.59
8.4.80.0100.00719.04
8.4.70.0130.00719.25
8.4.60.0130.00918.75
8.4.50.0120.01018.89
8.4.40.0160.00318.72
8.4.30.0170.00318.79
8.4.20.0100.01019.82
8.4.10.0060.00319.70
8.3.280.0160.01018.63
8.3.270.0130.00616.76
8.3.260.0100.00616.73
8.3.250.0070.00318.82
8.3.240.0100.00916.73
8.3.230.0140.00616.86
8.3.220.0120.00719.14
8.3.210.0040.00618.80
8.3.200.0050.00416.76
8.3.190.0060.00917.39
8.3.180.0030.00517.21
8.3.170.0140.00420.75
8.3.160.0000.01517.21
8.3.150.0120.00617.16
8.3.140.0090.00016.73
8.3.130.0110.00416.62
8.3.120.0090.00020.77
8.3.110.0040.00420.94
8.3.100.0050.00320.27
8.3.90.0110.00716.63
8.3.80.0030.00618.43
8.3.70.0070.01118.56
8.3.60.0070.01016.85
8.3.50.0110.01021.99
8.3.40.0160.01617.75
8.3.30.0240.00817.63
8.3.20.0220.00917.63
8.3.10.0280.00617.63
8.3.00.0220.01119.26
8.2.290.0100.00918.87
8.2.280.0040.00618.60
8.2.270.0110.00718.96
8.2.260.0080.00018.51
8.2.250.0040.00417.03
8.2.240.0060.00318.67
8.2.230.0030.00522.58
8.2.220.0080.00024.06
8.2.210.0070.00726.77
8.2.200.0120.00016.73
8.2.190.0080.00816.63
8.2.180.0260.00416.25
8.2.170.0270.00817.63
8.2.160.0300.00318.00
8.2.150.0220.01117.71
8.2.140.0240.00917.63
8.2.130.0250.00817.50
8.2.120.0250.00817.72
8.2.110.0310.00819.48
8.2.100.0250.01117.63
8.2.90.0190.01617.87
8.2.80.0390.00317.60
8.2.70.0140.01817.50
8.2.60.0200.01217.88
8.2.50.0240.00917.63
8.2.40.0300.00317.63
8.2.30.0230.00917.38
8.2.20.0250.00617.63
8.2.10.0240.01017.75
8.2.00.0320.00317.62
8.1.330.0130.00716.68
8.1.320.0060.00616.60
8.1.310.0150.00318.54
8.1.300.0000.00918.29
8.1.290.0080.00018.88
8.1.280.0070.01325.92
8.1.270.0200.01417.38
8.1.260.0290.00717.63
8.1.250.0330.00317.24
8.1.240.0250.00617.25
8.1.230.0260.00417.36
8.1.220.0170.01417.60
8.1.210.0220.00718.93
8.1.200.0190.01117.47
8.1.190.0320.00017.11
8.1.180.0270.00317.25
8.1.170.0210.00817.48
8.1.160.0270.00317.50
8.1.150.0310.00017.36
8.1.140.0290.00317.25
8.1.130.0230.00817.47
8.1.120.0290.00217.35
8.1.110.0240.00717.50
8.1.100.0270.00317.59
8.1.90.0090.00919.38
8.1.80.0000.01719.34
8.1.70.0070.01119.25
8.1.60.0080.00819.31
8.1.50.0100.00719.25
8.1.40.0140.00519.13
8.1.30.0000.01919.50
8.1.20.0080.00819.51
8.1.10.0120.00419.30
8.1.00.0050.01119.25

preferences:
33.61 ms | 403 KiB | 5 Q