3v4l.org

run code in 300+ PHP versions simultaneously
<?php function is_valid_date($value, $format = 'dd.mm.yyyy'){ if(strlen($value) >= 6 && strlen($format) == 10){ // find separator. Remove all other characters from $format $separator_only = str_replace(array('m','d','y'),'', $format); $separator = $separator_only[0]; // separator is first character if($separator && strlen($separator_only) == 2){ // make regex $regexp = str_replace('mm', '(0?[1-9]|1[0-2])', $format); $regexp = str_replace('dd', '(0?[1-9]|[1-2][0-9]|3[0-1])', $regexp); $regexp = str_replace('yyyy', '(19|20)?[0-9][0-9]', $regexp); echo ($regexp."<br>\n"); $regexp = str_replace($separator, "\\" . $separator, $regexp); echo ($regexp."<br>\n"); if($regexp != $value && preg_match('/'.$regexp.'\z/', $value)){ // check date $arr=explode($separator,$value); $day=$arr[0]; $month=$arr[1]; $year=$arr[2]; if(@checkdate($month, $day, $year)) return true; } } } return false; } var_dump(is_valid_date('22.22.2222', 'mm.dd.yyyy')); // returns false var_dump(is_valid_date('11/30/2008', 'mm/dd/yyyy')); // returns true var_dump(is_valid_date('30-01-2008', 'dd-mm-yyyy')); // returns true var_dump(is_valid_date('2008 01 30', 'yyyy mm dd')); // returns true

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.3.60.0170.00018.68
8.3.50.0220.00721.27
8.3.40.0150.00619.04
8.3.30.0030.01218.95
8.3.20.0080.00020.29
8.3.10.0040.00422.05
8.3.00.0040.00422.43
8.2.180.0090.00616.63
8.2.170.0070.01122.96
8.2.160.0040.01120.38
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0070.00426.16
8.2.120.0030.00519.66
8.2.110.0070.00322.23
8.2.100.0060.00619.13
8.2.90.0040.00419.34
8.2.80.0060.00319.40
8.2.70.0060.00317.88
8.2.60.0000.00917.93
8.2.50.0060.00318.07
8.2.40.0030.00518.34
8.2.30.0030.00618.32
8.2.20.0000.00818.02
8.2.10.0050.00317.97
8.2.00.0030.00518.04
8.1.280.0060.01225.92
8.1.270.0040.00420.40
8.1.260.0040.00426.35
8.1.250.0050.00328.09
8.1.240.0030.00623.81
8.1.230.0070.00419.22
8.1.220.0000.00817.74
8.1.210.0040.00418.77
8.1.200.0000.00917.61
8.1.190.0040.00417.54
8.1.180.0030.00518.77
8.1.170.0050.00518.84
8.1.160.0020.00522.15
8.1.150.0040.00418.88
8.1.140.0000.00817.55
8.1.130.0040.00417.95
8.1.120.0040.00417.69
8.1.110.0070.00417.49
8.1.100.0030.00517.57
8.1.90.0040.00417.60
8.1.80.0060.00317.62
8.1.70.0050.00217.50
8.1.60.0000.00817.76
8.1.50.0190.00517.71
8.1.40.0030.00517.72
8.1.30.0040.00417.78
8.1.20.0000.00817.73
8.1.10.0000.00917.80
8.1.00.0000.00817.68
8.0.300.0030.00518.77
8.0.290.0040.00417.29
8.0.280.0040.00418.41
8.0.270.0040.00417.30
8.0.260.0030.00317.14
8.0.250.0000.00917.20
8.0.240.0060.00317.16
8.0.230.0050.00317.15
8.0.220.0000.00717.07
8.0.210.0000.00817.13
8.0.200.0030.00317.24
8.0.190.0000.00717.16
8.0.180.0040.00417.18
8.0.170.0030.00517.11
8.0.160.0000.00817.07
8.0.150.0000.00817.13
8.0.140.0000.00817.02
8.0.130.0030.00313.65
8.0.120.0040.00417.15
8.0.110.0030.00517.11
8.0.100.0030.00517.04
8.0.90.0030.00517.16
8.0.80.0060.01217.19
8.0.70.0080.00017.16
8.0.60.0050.00217.05
8.0.50.0040.00417.11
8.0.30.0150.00917.22
8.0.20.0080.01217.40
8.0.10.0050.00217.16
8.0.00.0130.00616.95
7.4.330.0050.00015.00
7.4.320.0030.00316.74
7.4.300.0030.00316.84
7.4.290.0030.00316.65
7.4.280.0000.00716.88
7.4.270.0030.00316.76
7.4.260.0070.00016.68
7.4.250.0000.00816.60
7.4.240.0040.00416.85
7.4.230.0000.00816.73
7.4.220.0150.00616.87
7.4.210.0060.01016.79
7.4.200.0040.00416.89
7.4.190.0040.00416.65
7.4.160.0130.00316.58
7.4.150.0160.00317.40
7.4.140.0120.00717.86
7.4.130.0150.00616.73
7.4.120.0080.00916.86
7.4.110.0130.00316.79
7.4.100.0170.00716.71
7.4.90.0180.00416.55
7.4.80.0050.01719.39
7.4.70.0090.00916.73
7.4.60.0100.00616.80
7.4.50.0040.00416.59
7.4.40.0100.00722.77
7.4.30.0060.01016.81
7.4.00.0080.01015.37
7.3.330.0000.00513.52
7.3.320.0050.00013.29
7.3.310.0040.00416.55
7.3.300.0070.00016.45
7.3.290.0040.01116.50
7.3.280.0060.01016.54
7.3.270.0100.00717.40
7.3.260.0100.01616.63
7.3.250.0080.00916.73
7.3.240.0180.00016.71
7.3.230.0180.00616.71
7.3.210.0070.01016.61
7.3.200.0130.00319.39
7.3.190.0040.01816.63
7.3.180.0040.01216.78
7.3.170.0120.00416.91
7.3.160.0090.00616.82
7.3.120.0110.00615.08
7.3.110.0060.00914.89
7.3.100.0090.00615.20
7.3.90.0110.00415.14
7.3.80.0030.01215.05
7.3.70.0090.00615.08
7.3.60.0070.00715.15
7.3.50.0040.01115.02
7.3.40.0070.01014.86
7.3.30.0000.01015.12
7.3.20.0030.00916.75
7.3.10.0080.00816.95
7.3.00.0070.00516.94
7.2.330.0080.01016.93
7.2.320.0100.00716.89
7.2.310.0200.00316.93
7.2.300.0000.01716.90
7.2.290.0070.01016.75
7.2.250.0030.01615.43
7.2.240.0070.01315.34
7.2.230.0100.00615.42
7.2.220.0000.01615.07
7.2.210.0070.00715.08
7.2.200.0040.01415.45
7.2.190.0070.00315.35
7.2.180.0070.01015.29
7.2.170.0040.01215.42
7.2.130.0060.00617.16
7.2.120.0060.00617.19
7.2.110.0030.00916.96
7.2.100.0060.00616.94
7.2.90.0000.01417.03
7.2.80.0090.00617.31
7.2.70.0100.00617.11
7.2.60.0060.01017.27
7.2.50.0130.00417.21
7.2.40.0080.00517.13
7.2.30.0090.00917.27
7.2.20.0060.00817.25
7.2.10.0030.00717.20
7.2.00.0070.00517.99
7.1.330.0110.00416.08
7.1.320.0090.00616.24
7.1.310.0040.00816.07
7.1.300.0030.01316.05
7.1.290.0090.00315.88
7.1.280.0060.00916.20
7.1.270.0000.01515.93
7.1.260.0090.00616.15
7.1.250.0070.00516.04
7.1.200.0190.01015.66
7.1.70.0050.00517.60
7.1.60.0030.00717.75
7.1.50.0100.01317.23
7.1.00.0000.06722.34
7.0.200.0030.01317.04
7.0.140.0000.07721.99
7.0.60.0100.05319.97
7.0.50.0130.06317.89
7.0.40.0100.07020.34
7.0.30.0270.03320.09
7.0.20.0230.03720.25
7.0.10.0270.04320.19
7.0.00.0030.04320.23
5.6.280.0030.07321.09
5.6.210.0170.05720.74
5.6.200.0000.04318.20
5.6.190.0100.05320.54
5.6.180.3730.05020.68
5.6.170.0370.05020.46
5.6.160.0070.09020.59
5.6.150.0070.04318.18
5.6.140.0030.09018.16
5.6.130.0100.07718.15
5.6.120.0070.05721.03
5.6.110.0100.08320.98
5.6.100.0030.08720.96
5.6.90.0100.06721.09
5.6.80.0070.03720.38
5.6.70.0200.07320.40
5.5.350.0130.08020.49
5.5.340.0070.04018.08
5.5.330.0130.05020.28
5.5.320.0200.05320.24
5.5.310.0300.07020.20
5.5.300.0070.07717.96
5.5.290.0130.07717.96
5.5.280.0030.04020.88
5.5.270.0100.06020.90
5.5.260.0130.08020.78
5.5.250.0070.08320.65
5.5.240.0070.07720.14
5.4.450.0700.06019.62
5.4.440.0730.06319.29
5.4.430.0170.05319.47
5.4.420.0670.07719.32
5.4.410.0800.05719.46
5.4.400.0300.06318.79
5.4.390.1030.07018.80
5.4.380.0300.05018.55
5.4.370.0200.04718.77
5.4.360.0170.04718.77
5.4.350.0050.03612.03
5.4.340.0090.04212.02
5.4.320.0080.04812.51
5.4.310.0050.03912.51
5.4.300.0060.04712.52
5.4.290.0090.04512.51
5.4.280.0060.04012.41
5.4.270.0080.04112.41
5.4.260.0100.03212.41
5.4.250.0100.04719.03
5.4.240.0000.06018.96
5.4.230.0000.05718.91
5.4.220.0030.05718.86
5.4.210.0030.05718.80
5.4.200.0030.06318.65
5.4.190.0200.06018.92
5.4.180.0030.05718.80
5.4.170.0030.05718.80
5.4.160.0170.06018.89
5.4.150.0030.05718.73
5.4.140.0170.04316.61
5.4.130.0000.05316.48
5.4.120.0100.04716.45
5.4.110.0030.07016.39
5.4.100.0000.05716.55
5.4.90.0070.04716.45
5.4.80.0100.04316.45
5.4.70.0070.06716.32
5.4.60.0000.05316.49
5.4.50.0000.05716.49
5.4.40.0100.05016.65
5.4.30.0130.04316.54
5.4.20.0030.05316.44
5.4.10.0070.05016.49
5.4.00.0130.05316.00
5.3.290.0040.04512.80
5.3.280.0000.05714.79
5.3.270.0100.05014.79
5.3.260.0030.07014.73
5.3.250.0170.04314.79
5.3.240.0070.05014.71
5.3.230.0130.04314.69
5.3.220.0030.05314.41
5.3.210.0030.05314.72
5.3.200.0070.04714.80
5.3.190.0170.05314.67
5.3.180.0100.04314.64
5.3.170.0070.04714.66
5.3.160.0100.05014.41
5.3.150.0030.05714.66
5.3.140.0070.05314.59
5.3.130.0030.05314.73
5.3.120.0070.05014.57
5.3.110.0070.05014.64
5.3.100.0170.04013.95
5.3.90.0070.05314.00
5.3.80.0170.04314.11
5.3.70.0100.04714.12
5.3.60.0030.05314.09
5.3.50.0030.05313.93
5.3.40.0000.05714.04
5.3.30.0230.04714.10
5.3.20.0130.04013.80
5.3.10.0030.05013.68
5.3.00.0030.05313.87
5.2.170.0030.06311.16
5.2.160.0070.03711.25
5.2.150.0030.05711.23
5.2.140.0000.04711.32
5.2.130.0100.03711.20
5.2.120.0000.04311.20
5.2.110.0100.03311.07
5.2.100.0070.03711.09
5.2.90.0130.05711.20
5.2.80.0030.06311.09
5.2.70.0000.04311.18
5.2.60.0000.04311.15
5.2.50.0000.04310.94
5.2.40.0100.03311.11
5.2.30.0070.04011.18
5.2.20.0070.03710.89
5.2.10.0070.03710.96
5.2.00.0070.03710.83
5.1.60.0070.0309.99
5.1.50.0030.03710.25
5.1.40.0100.0409.96
5.1.30.0000.04010.36
5.1.20.0070.03310.36
5.1.10.0000.04010.14
5.1.00.0030.04310.07
5.0.50.0000.0308.80
5.0.40.0100.0308.58
5.0.30.0000.0638.33
5.0.20.0070.0338.19
5.0.10.0070.0378.03
5.0.00.0070.0378.02
4.4.90.0000.0236.70
4.4.80.0070.0176.70
4.4.70.0030.0306.70
4.4.60.0000.0236.70
4.4.50.0000.0236.70
4.4.40.0030.0336.70
4.4.30.0030.0206.70
4.4.20.0000.0236.70
4.4.10.0000.0276.70
4.4.00.0000.0376.70
4.3.110.0030.0276.70
4.3.100.0000.0236.70
4.3.90.0030.0276.70
4.3.80.0030.0336.70
4.3.70.0030.0206.70
4.3.60.0100.0136.70
4.3.50.0000.0336.70
4.3.40.0000.0336.70
4.3.30.0000.0236.70
4.3.20.0000.0236.70
4.3.10.0000.0236.70
4.3.00.0100.0237.10

preferences:
50.71 ms | 401 KiB | 5 Q