3v4l.org

run code in 300+ PHP versions simultaneously
<?php $datetime1 = new \DateTimeImmutable('9999-01-02 15:00:00.000000', new \DateTimeZone('UTC')); try { $datetime2 = $datetime1->add(new \DateInterval('P1Y')); echo $datetime2->format('Y-m-d H:i:s.u') . \PHP_EOL; } catch (\Throwable $e) { echo 'exception' . \PHP_EOL; } $datetime3 = \DateTimeImmutable::createFromFormat('Y-m-d H:i:s.u', $datetime2->format('Y-m-d H:i:s.u'), new \DateTimeZone('UTC')); if ($datetime3 !== false) { echo $datetime3->format('Y-m-d H:i:s.u') . \PHP_EOL; } else { echo 'false' . \PHP_EOL; } try { $datetime4 = new \DateTimeImmutable($datetime2->format('Y-m-d H:i:s.u'), new \DateTimeZone('UTC')); echo $datetime4->format('Y-m-d H:i:s.u') . \PHP_EOL; } catch (\Throwable $e) { echo 'exception' . \PHP_EOL; } // Workaround with fake year try { $datetime5 = new \DateTimeImmutable($datetime2->format('1234-m-d H:i:s.u'), new \DateTimeZone('UTC')); $datetime5 = $datetime5->setDate((int)$datetime2->format("Y"), (int)$datetime2->format("n"), (int)$datetime2->format("j")); echo $datetime5->format('Y-m-d H:i:s.u') . \PHP_EOL; } catch (\Throwable $e) { echo 'exception' . \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.1.100.0050.00217.86
8.1.90.0000.00717.87
8.1.80.0000.00817.80
8.1.70.0070.00017.83
8.1.60.0040.00417.91
8.1.50.0060.00317.88
8.1.40.0040.00417.89
8.1.30.0000.00917.97
8.1.20.0000.00817.94
8.1.10.0070.00017.94
8.1.00.0050.00317.82
8.0.230.0000.00717.36
8.0.220.0030.00317.40
8.0.210.0070.00017.36
8.0.200.0000.00717.45
8.0.190.0080.00017.27
8.0.180.0050.00217.40
8.0.170.0000.00917.35
8.0.160.0040.00417.25
8.0.150.0030.00517.27
8.0.140.0070.00017.34
8.0.130.0000.00613.84
8.0.120.0040.00417.37
8.0.110.0000.00817.37
8.0.100.0050.00217.30
8.0.90.0040.00417.41
8.0.80.0040.00417.30
8.0.70.0020.00517.41
8.0.60.0040.00417.34
8.0.50.0040.00417.34
8.0.30.0040.00417.30
8.0.20.0030.00317.30
8.0.10.0000.00717.51
8.0.00.0000.00717.38
7.4.300.0030.00316.97
7.4.290.0030.00516.95
7.4.280.0000.00716.92
7.4.270.0040.00416.94
7.4.260.0000.00613.67
7.4.250.0040.00416.84
7.4.240.0070.00016.93
7.4.230.0000.00816.92
7.4.220.0000.00716.93
7.4.210.0040.00416.88
7.4.200.0030.00516.79
7.4.190.0030.00516.97
7.4.180.0000.00716.97
7.4.160.0080.00016.81
7.4.150.0080.00016.93
7.4.140.0070.00016.79
7.4.130.0070.00016.72
7.4.120.0050.00216.91
7.4.110.0030.00316.76
7.4.100.0070.00016.85
7.4.90.0020.00516.76
7.4.80.0070.00016.69
7.4.70.0030.00316.64
7.4.60.0080.00016.80
7.4.50.0030.00516.66
7.4.40.0050.00216.91
7.4.30.0000.00716.96
7.4.20.0050.00316.75
7.4.10.0070.00016.86
7.4.00.0050.00316.85
7.3.330.0090.00016.66
7.3.320.0030.00313.76
7.3.310.0030.00516.86
7.3.300.0000.00916.74
7.3.290.0090.00016.74
7.3.280.0000.00816.56
7.3.270.0000.00716.78
7.3.260.0000.00716.65
7.3.250.0030.00316.64
7.3.240.0000.00716.77
7.3.230.0000.00816.75
7.3.220.0000.00716.68
7.3.210.0070.00016.75
7.3.200.0030.00316.62
7.3.190.0030.00316.60
7.3.180.0030.00316.62
7.3.170.0060.00016.57
7.3.160.0040.00416.70
7.3.150.0040.00416.70
7.3.140.0000.00816.73
7.3.130.0000.00716.68
7.3.120.0030.00316.74
7.3.110.0040.00416.52
7.3.100.0070.00016.68
7.3.90.0030.00316.92
7.3.80.0020.00516.56
7.3.70.0060.00016.78
7.3.60.0000.00816.83
7.3.50.0030.00316.83
7.3.40.0000.00716.79
7.3.30.0070.00016.70
7.3.20.0030.00318.42
7.3.10.0030.00318.39
7.3.00.0040.00418.45

preferences:
11.3 ms | 406 KiB | 5 Q