3v4l.org

run code in 300+ PHP versions simultaneously
<?php function roundTime($timestamp, $interval, $direction){ $rounded_seconds = 0; switch ($direction) { case "u": //round up $rounded_seconds = ceil($timestamp / ($interval * 60)) * ($interval * 60); break; case "d": //round down $rounded_seconds = floor($timestamp / ($interval * 60)) * ($interval * 60); break; default: echo "default"; } return date('H:i', $rounded_seconds) . "\n"; } $testTimes = [ "2023-05-30 14:05", "2023-05-30 14:23", "2023-05-30 14:35", "2023-05-30 14:40", "2023-05-30 14:55" ]; foreach ($testTimes as $time) { echo "base time: ".$time.PHP_EOL; echo "round up to 15 mins: ".roundTime(strtotime($time), 15, "u"); echo "round up to 30 mins: ".roundTime(strtotime($time), 30, "u"); echo "round down to 15 mins: ".roundTime(strtotime($time), 15, "d"); echo "round down to 30 mins: ".roundTime(strtotime($time), 30, "d"); echo PHP_EOL; }

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.30.0120.00619.48
8.5.20.0080.01020.08
8.5.10.0090.00919.43
8.5.00.0110.01020.17
8.4.180.0100.01319.77
8.4.170.0150.00720.55
8.4.160.0140.01023.63
8.4.150.0080.00516.94
8.4.140.0120.01017.46
8.4.130.0120.00917.75
8.4.120.0120.00820.43
8.4.110.0110.00922.41
8.4.100.0140.00717.86
8.4.90.0170.00417.94
8.4.80.0100.01118.04
8.4.70.0130.00518.09
8.4.60.0100.01117.88
8.4.50.0150.00518.68
8.4.40.0070.01417.68
8.4.30.0160.00320.71
8.4.20.0040.01219.68
8.4.10.0030.01619.72
8.3.300.0150.00920.80
8.3.290.0090.01320.82
8.3.280.0110.00918.61
8.3.270.0080.01216.88
8.3.260.0130.00716.69
8.3.250.0110.00818.82
8.3.240.0070.00916.82
8.3.230.0120.00816.50
8.3.220.0090.01017.22
8.3.210.0040.00916.82
8.3.200.0130.00616.64
8.3.190.0110.00816.64
8.3.180.0110.00816.61
8.3.170.0160.00319.03
8.3.160.0130.00616.85
8.3.150.0130.00617.41
8.3.140.0000.00918.58
8.3.130.0100.00016.59
8.3.120.0090.00020.39
8.3.110.0360.00616.58
8.3.100.0200.00316.61
8.3.90.0230.00416.47
8.3.80.0320.00016.37
8.3.70.0210.00416.75
8.3.60.0300.01316.00
8.3.50.0430.00016.34
8.3.40.0400.00017.50
8.3.30.0280.01117.36
8.3.20.0290.00617.11
8.3.10.0360.00317.63
8.3.00.0270.00917.38
8.2.300.0130.00722.23
8.2.290.0130.00618.92
8.2.280.0100.00916.55
8.2.270.0070.01116.89
8.2.260.0030.00716.89
8.2.250.0060.00318.57
8.2.240.0090.00017.13
8.2.230.0280.01316.60
8.2.220.0230.01316.42
8.2.210.0320.00916.61
8.2.200.0380.00316.34
8.2.190.0270.01516.71
8.2.180.0330.00716.41
8.2.170.0380.01317.47
8.2.160.0370.00417.50
8.2.150.0360.01017.63
8.2.140.0330.00617.38
8.2.130.0290.00617.50
8.2.120.0280.00717.75
8.2.110.0290.00017.75
8.2.100.0140.00617.75
8.2.90.0270.00417.63
8.2.80.0330.00917.50
8.2.70.0310.01417.50
8.2.60.0280.01217.50
8.2.50.0160.01217.75
8.2.40.0260.00317.63
8.2.30.0290.01317.63
8.2.20.0280.00017.50
8.2.10.0130.00617.75
8.2.00.0150.00417.63
8.1.340.0110.00919.56
8.1.330.0110.00817.89
8.1.320.0120.00717.79
8.1.310.0140.00318.73
8.1.300.0110.00718.32
8.1.290.0070.00316.23
8.1.280.0130.00715.75
8.1.270.0040.01617.33
8.1.260.0170.00417.61
8.1.250.0220.00417.50
8.1.240.0190.00717.50
8.1.230.0290.00417.50
8.1.220.0330.00517.25
8.1.210.0170.01717.50
8.1.200.0180.00417.63
8.1.190.0230.02017.36
8.1.180.0150.00517.24
8.1.170.0240.01417.48
8.1.160.0250.01317.60
8.1.150.0120.00617.72
8.1.140.0290.00617.50
8.1.130.0210.01417.46
8.1.120.0220.00617.36
8.1.110.0190.00017.48
8.1.100.0200.01017.38
8.1.90.0130.01017.63
8.1.80.0100.00717.75
8.1.70.0240.00317.38
8.1.60.0270.00017.35
8.1.50.0200.00017.63
8.1.40.0210.00017.35
8.1.30.0190.00617.50
8.1.20.0100.01017.38
8.1.10.0200.00017.24
8.1.00.0320.00617.38

preferences:
51.9 ms | 1059 KiB | 5 Q