3v4l.org

run code in 300+ PHP versions simultaneously
<?php function isValidDate(string $date, string $format = 'm/d/Y', string $yearPadding = '19'): bool { $date = preg_replace_callback( '~^(\d+)(\D)(\d+)\2(\d+)$~', fn($m) => sprintf('%02d/%02d/%d', $m[1], $m[3], str_pad($m[4], 4, $yearPadding, STR_PAD_LEFT)), $date ); // sanitize $d = DateTime::createFromFormat($format, $date); // attempt to parse return $d && $d->format($format) === $date; // check if formatted string is same as sanitized string } $tests = [ '1-1-1992', '1-1-92', '1-01-1992', '1-01-92', '01-1-1992', '01-1-92', '01-01-1992', '01-01/92', '1/1/1992', '1/1/92', '1/01/1992', '1/01/92', '01/1/199', '01/1/92', '01/01/1992', '01/01/92' ]; var_export(array_map('isValidDate', $tests));

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.4.130.0050.00319.59
8.4.120.0080.01222.41
8.4.110.0060.00322.41
8.4.100.0120.00817.83
8.4.90.0110.00820.94
8.4.80.0120.00818.88
8.4.70.0060.00319.00
8.4.60.0040.00518.99
8.4.50.0090.01118.78
8.4.40.0170.00318.27
8.4.30.0130.00620.43
8.4.20.0140.00719.89
8.4.10.0060.00318.32
8.3.260.0120.00816.86
8.3.250.0120.00619.00
8.3.240.0100.00816.95
8.3.230.0130.00616.81
8.3.220.0100.00918.95
8.3.210.0060.00216.88
8.3.200.0080.00816.92
8.3.190.0030.00617.18
8.3.180.0120.00519.03
8.3.170.0150.00418.84
8.3.160.0030.01418.47
8.3.150.0090.00618.91
8.3.140.0040.00420.73
8.3.130.0060.00318.62
8.3.120.0050.00319.18
8.3.110.0040.00416.89
8.3.100.0080.00016.63
8.3.90.0060.01226.77
8.3.80.0030.00616.88
8.3.70.0000.01516.58
8.3.60.0090.00618.43
8.3.50.0070.00720.39
8.3.40.0030.01020.32
8.3.30.0070.00719.07
8.3.20.0070.00024.18
8.3.10.0050.00324.66
8.3.00.0040.00426.16
8.2.290.0100.00620.45
8.2.280.0120.00820.42
8.2.270.0160.00316.95
8.2.260.0040.01117.29
8.2.250.0040.00416.73
8.2.240.0110.00816.85
8.2.230.0000.00820.94
8.2.220.0000.00824.06
8.2.210.0150.00326.77
8.2.200.0000.01016.75
8.2.190.0070.00716.59
8.2.180.0100.00625.92
8.2.170.0120.00319.21
8.2.160.0150.00322.96
8.2.150.0030.00625.66
8.2.140.0080.00024.66
8.2.130.0080.00026.16
8.2.120.0100.00026.16
8.2.110.0090.00022.28
8.2.100.0040.00818.16
8.2.90.0080.00018.13
8.2.80.0060.00319.16
8.2.70.0040.00418.00
8.2.60.0050.00518.00
8.2.50.0000.00817.98
8.2.40.0000.00918.22
8.2.30.0000.00818.24
8.2.20.0000.00720.54
8.2.10.0040.00417.99
8.2.00.0050.00219.43
8.1.330.0100.01022.19
8.1.320.0100.00918.31
8.1.310.0120.00616.85
8.1.300.0060.00318.81
8.1.290.0030.00930.84
8.1.280.0100.01025.92
8.1.270.0000.00823.99
8.1.260.0040.00426.35
8.1.250.0050.00328.09
8.1.240.0060.00323.82
8.1.230.0000.01117.81
8.1.220.0000.00817.78
8.1.210.0030.00618.77
8.1.200.0060.00317.60
8.1.190.0060.00317.73
8.1.180.0030.00618.10
8.1.170.0090.00017.91
8.1.160.0000.00719.07
8.1.150.0110.00018.98
8.1.140.0030.00617.72
8.1.130.0040.00417.89
8.1.120.0040.00417.74
8.1.110.0000.00817.75
8.1.100.0000.00817.80
8.1.90.0000.00717.73
8.1.80.0030.00617.73
8.1.70.0040.00417.77
8.1.60.0030.00917.86
8.1.50.0000.00817.83
8.1.40.0030.00517.66
8.1.30.0030.00617.79
8.1.20.0180.00417.86
8.1.10.0200.00317.82
8.1.00.0220.00217.82
8.0.300.0040.00418.77
8.0.290.0050.00517.25
8.0.280.0030.00518.62
8.0.270.0040.00417.08
8.0.260.0000.00717.14
8.0.250.0000.00817.30
8.0.240.0000.00717.21
8.0.230.0080.00017.32
8.0.220.0040.00417.28
8.0.210.0000.00717.23
8.0.200.0040.00417.40
8.0.190.0030.00517.32
8.0.180.0000.00817.18
8.0.170.0030.00617.26
8.0.160.0170.00317.21
8.0.150.0160.00617.21
8.0.140.0150.00717.27
8.0.130.0180.00517.18
8.0.120.0200.00417.18
8.0.110.0160.00517.21
8.0.100.0180.00517.11
8.0.90.0170.00417.29
8.0.80.0200.00217.14
8.0.70.0240.00317.26
8.0.60.0170.00917.12
8.0.50.0150.00717.16
8.0.30.0120.00017.13
8.0.20.0200.00317.26
8.0.10.0180.00417.35
7.4.330.0060.00015.55
7.4.320.0000.00616.90
7.4.300.0070.00316.91
7.4.290.0000.00816.70
7.4.280.0120.00616.83
7.4.270.0060.01116.96
7.4.260.0140.00416.87
7.4.250.0210.00516.82
7.4.240.0220.00016.83
7.4.230.0190.00616.83
7.4.220.0120.00817.04
7.4.210.0180.00716.97
7.4.200.0170.00716.90
7.4.190.0140.00016.98
7.4.180.0080.00416.99
7.4.160.0080.00017.01
7.4.150.0000.01016.83
7.4.140.0080.00816.78
7.4.130.0180.00516.84
7.4.120.0140.00616.77
7.4.110.0190.00316.76
7.4.100.0160.00317.00
7.4.90.0130.00716.82
7.4.80.0130.00716.82
7.4.70.0080.01216.80
7.4.60.0100.00716.93
7.4.50.0060.00616.80
7.4.40.0110.00616.73
7.4.30.0170.00316.86
7.4.20.0150.00516.66
7.4.10.0120.00616.73
7.4.00.0110.00816.79

preferences:
30.89 ms | 403 KiB | 5 Q