3v4l.org

run code in 300+ PHP versions simultaneously
<?php $filenameNew = 'PX20170713_103320_2651093_00001'; $filenameOld = '5956e5781e4f1-20170630_233347_5712837_00001.xml'; //$timeslug = implode(array_slice(explode('_', rtrim(basename($fileToProcess), ".xml" )), 0, 2)); //$datetime = date('c', strtotime($timeslug)); /** * Get a date time object from an AX filename. * * Example filename: PX20170713_103320_2651093_00001.xml */ function getDateFromFilename(string $filename): ?DateTime { // Find the first block of 4-2-2 numbers. $dateRegexp = '/([0-9]{4})([0-9]{2})([0-9]{2})/'; // Find the first block of 2-2-2 numbers $timeRegexp = '/([0-9]{2})([0-9]{2})([0-9]{2})/'; // We could do the regex directly to the filename but by extracting // the date and time from the filename string we retain a level of // safety in that we can not accidentally regexp the wrong value. try { list($date, $time) = explode('_', $filename); } catch (\Throwable $t) { throw new \Exception(sprintf( 'Could not split the date up from the filename for %s', $filename )); } // Regex the date and drop the first array index(the entire string block) try { preg_match($dateRegexp, $date, $dateParts); unset($dateParts[0]); } catch (\Throwable $t) { throw new \Exception(sprintf( 'Could not extrapolate the date from the filename %s', $filename )); } // Regex the time try { preg_match($timeRegexp, $time, $timeParts); unset($timeParts[0]); } catch (\Throwable $t) { throw new \Exception(sprintf( 'Could not extrapolate the time from the filename %s', $filename )); } // Create a new datetime instance and set the date from the regex results. try { $dateTime = new \DateTime(); $dateTime->setDate($dateParts[1], $dateParts[2], $dateParts[3]); $dateTime->setTime($timeParts[1], $timeParts[2], $timeParts[3]); } catch (\Throwable $t) { throw new \Exception(sprintf( 'Could not build the date time from the filename %s', $filename )); return null; } return $dateTime; } var_dump(getDateFromFilename($filenameNew));

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.0090.00918.68
8.3.50.0040.01216.92
8.3.40.0040.01219.17
8.3.30.0060.01219.04
8.3.20.0080.00020.20
8.3.10.0090.00023.65
8.3.00.0080.00019.68
8.2.180.0130.00317.13
8.2.170.0180.00322.96
8.2.160.0140.00019.29
8.2.150.0040.00424.18
8.2.140.0000.00824.66
8.2.130.0040.00419.32
8.2.120.0070.00026.35
8.2.110.0140.00420.38
8.2.100.0090.00317.93
8.2.90.0000.00919.41
8.2.80.0050.00317.97
8.2.70.0030.00517.88
8.2.60.0080.00017.93
8.2.50.0040.00418.10
8.2.40.0040.00420.66
8.2.30.0060.00319.30
8.2.20.0000.00818.28
8.2.10.0040.00418.19
8.2.00.0040.00418.30
8.1.280.0090.00925.92
8.1.270.0080.00022.14
8.1.260.0050.00326.35
8.1.250.0080.00028.09
8.1.240.0070.00320.71
8.1.230.0090.00319.10
8.1.220.0030.00617.78
8.1.210.0050.00318.77
8.1.200.0070.00317.72
8.1.190.0040.00417.60
8.1.180.0000.00918.10
8.1.170.0030.00518.98
8.1.160.0000.00719.01
8.1.150.0000.01018.95
8.1.140.0000.00719.60
8.1.130.0000.00717.78
8.1.120.0040.00417.66
8.1.110.0040.00417.60
8.1.100.0040.00417.65
8.1.90.0000.00817.80
8.1.80.0040.00417.76
8.1.70.0050.00217.66
8.1.60.0050.00317.79
8.1.50.0000.00817.72
8.1.40.0040.00417.81
8.1.30.0030.00617.79
8.1.20.0000.00817.96
8.1.10.0000.00817.74
8.1.00.0070.00017.90
8.0.300.0000.00818.77
8.0.290.0040.00417.00
8.0.280.0050.00218.51
8.0.270.0000.00717.13
8.0.260.0000.00717.12
8.0.250.0070.00017.23
8.0.240.0080.00017.15
8.0.230.0080.00317.32
8.0.220.0030.00517.20
8.0.210.0030.00317.23
8.0.200.0050.00317.17
8.0.190.0060.00317.23
8.0.180.0040.00417.12
8.0.170.0040.00417.29
8.0.160.0050.00317.21
8.0.150.0050.00317.09
8.0.140.0050.00317.14
8.0.130.0000.00613.64
8.0.120.0040.00417.09
8.0.110.0040.00417.08
8.0.100.0000.00717.01
8.0.90.0000.00917.20
8.0.80.0130.00717.24
8.0.70.0000.00817.31
8.0.60.0000.00717.05
8.0.50.0040.00417.20
8.0.30.0130.00717.58
8.0.20.0120.00817.41
8.0.10.0050.00217.17
8.0.00.0150.00916.98
7.4.330.0000.00615.55
7.4.320.0030.00317.02
7.4.300.0030.00316.88
7.4.290.0030.00317.00
7.4.280.0050.00316.78
7.4.270.0080.00016.87
7.4.260.0000.00816.93
7.4.250.0070.00016.91
7.4.240.0030.00517.02
7.4.230.0030.00316.85
7.4.220.0160.01316.91
7.4.210.0090.01216.82
7.4.200.0030.00417.05
7.4.160.0100.00816.84
7.4.150.0030.01517.40
7.4.140.0140.00717.86
7.4.130.0130.00616.93
7.4.120.0100.01116.95
7.4.110.0090.00916.89
7.4.100.0120.00616.62
7.4.90.0030.01316.93
7.4.80.0170.00619.39
7.4.70.0030.01316.94
7.4.60.0100.01016.83
7.4.50.0030.01316.82
7.4.40.0180.00016.85
7.4.30.0090.00616.83
7.4.00.0080.00915.51
7.3.330.0050.00013.52
7.3.320.0030.00313.59
7.3.310.0030.00316.69
7.3.300.0070.00016.71
7.3.290.0080.00616.67
7.3.280.0080.00816.62
7.3.270.0170.00317.40
7.3.260.0120.00816.64
7.3.250.0160.00616.75
7.3.240.0080.00916.69
7.3.230.0070.01516.88
7.3.210.0030.01416.89
7.3.200.0080.00817.01
7.3.190.0070.01016.73
7.3.180.0060.01016.66
7.3.170.0040.01316.88
7.3.160.0120.00616.75
7.3.120.0070.00915.16
7.3.110.0050.01315.02
7.3.100.0070.00815.16
7.3.90.0060.00615.14
7.3.80.0070.00815.17
7.3.70.0050.00915.02
7.3.60.0040.01315.07
7.3.50.0020.00715.18
7.3.40.0010.01215.12
7.3.30.0070.00315.09
7.3.20.0060.00516.99
7.3.10.0030.01016.84
7.3.00.0060.00616.87
7.2.330.0110.00717.08
7.2.320.0060.01217.03
7.2.310.0060.01117.00
7.2.300.0050.01417.09
7.2.290.0140.00517.05
7.2.250.0050.01315.49
7.2.240.0080.01115.34
7.2.230.0060.00915.35
7.2.220.0070.00915.21
7.2.210.0060.00815.38
7.2.200.0060.01015.31
7.2.190.0030.01315.41
7.2.180.0030.00915.24
7.2.170.0110.00515.45
7.2.160.0000.01715.36
7.2.150.0000.00917.29
7.2.140.0030.01017.34
7.2.130.0090.00017.29
7.2.120.0110.00417.34
7.2.110.0060.00317.34
7.2.100.0040.00817.14
7.2.90.0060.00917.33
7.2.80.0080.01117.12
7.2.70.0040.01517.31
7.2.60.0020.01317.21
7.2.50.0070.00717.29
7.2.40.0030.01317.08
7.2.30.0100.00717.28
7.2.20.0060.00617.07
7.2.10.0100.00717.03
7.2.00.0050.00918.39
7.1.330.0090.00716.02
7.1.320.0120.00116.18
7.1.310.0050.00716.12
7.1.300.0060.00616.10
7.1.290.0040.00816.14
7.1.280.0050.01116.08
7.1.270.0090.00416.25
7.1.260.0060.00816.19
7.1.250.0060.00316.04
7.1.240.0100.00316.25
7.1.230.0040.00716.04
7.1.220.0070.00416.02
7.1.210.0150.00016.06
7.1.200.0090.00416.07
7.1.190.0070.01016.40
7.1.180.0000.01316.20
7.1.170.0050.00516.13
7.1.160.0070.01316.30
7.1.150.0110.00316.25
7.1.140.0090.00615.96
7.1.130.0090.00616.01
7.1.120.0080.00316.16
7.1.110.0030.01216.28
7.1.100.0050.00817.31
7.1.90.0070.01016.38
7.1.80.0000.01516.29
7.1.70.0070.00616.82
7.1.60.0110.01225.73
7.1.50.0110.01425.70
7.1.40.0120.01725.54
7.1.30.0190.00825.50
7.1.20.0170.00825.52
7.1.10.0070.01116.68
7.1.00.0070.00916.54
7.0.330.0070.00715.20
7.0.320.0000.01315.24
7.0.310.0050.00515.29
7.0.300.0030.00715.03
7.0.290.0000.01415.38
7.0.280.0090.00915.06
7.0.270.0110.00415.26
7.0.260.0000.01115.32
7.0.250.0000.01415.10
7.0.240.0040.00715.23
7.0.230.0030.01015.44
7.0.220.0030.01015.35
7.0.210.0050.00515.36
7.0.200.0020.01315.84
7.0.190.0020.01316.00
7.0.180.0080.00815.72
7.0.170.0030.01315.59
7.0.160.0040.01315.60
7.0.150.0080.00715.71
7.0.140.0090.00715.63
7.0.130.0110.00715.83
7.0.120.0090.00615.73
7.0.110.0080.01115.66
7.0.100.0080.00815.63
7.0.90.0080.01015.71
7.0.80.0090.00915.94
7.0.70.0120.00415.54
7.0.60.0090.00415.69
7.0.50.0020.01615.69
7.0.40.0070.00514.96
7.0.30.0040.00914.94
7.0.20.0110.00514.90
7.0.10.0090.00614.90
7.0.00.0070.00714.90
5.6.400.0100.00314.30
5.6.390.0130.00314.16
5.6.380.0080.00814.34
5.6.370.0060.01214.32
5.6.360.0000.01414.32
5.6.350.0150.00414.29
5.6.340.0060.01214.11
5.6.330.0030.01314.26
5.6.320.0030.01314.23
5.6.310.0090.00314.02
5.6.300.0120.00013.74
5.6.290.0120.00614.17
5.6.280.0030.01114.07
5.6.270.0040.01114.07
5.6.260.0090.00914.33
5.6.250.0100.00714.24
5.6.240.0030.01514.10
5.6.230.0090.00914.11
5.6.220.0040.00814.46
5.6.210.0120.00014.13
5.6.200.0030.00914.39
5.6.190.0030.00613.96
5.6.180.0000.01114.35
5.6.170.0060.00314.24
5.6.160.0030.01214.24
5.6.150.0070.00714.06
5.6.140.0030.01014.36
5.6.130.0130.00314.13
5.6.120.0090.00614.24
5.6.110.0030.01314.20
5.6.100.0030.00914.24
5.6.90.0030.01013.94
5.6.80.0040.00814.25
5.6.70.0030.01014.17
5.6.60.0060.00913.98
5.6.50.0100.00614.35
5.6.40.0060.00313.98
5.6.30.0090.00613.93
5.6.20.0070.00313.94
5.6.10.0090.00014.10
5.6.00.0040.00414.32

preferences:
73.99 ms | 401 KiB | 5 Q