3v4l.org

run code in 300+ PHP versions simultaneously
<?php $filenameNew = 'PX20170713_103320_2651093_00001'; $filenameOld = '5956e5781e4f1-20170630_233347_5712837_00001'; $timeslug = implode(array_slice(explode('_', rtrim(basename($fileToProcess), ".xml" )), 0, 2)); $datetime = date('c', strtotime($timeslug)); function getDateFromFilename(string $filename): string { $timeslug = implode(array_slice(explode('_', $filename), 0, 2)); return date('c', strtotime($timeslug)); } var_dump(getDateFromFilename($filenameOld));
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Warning: Undefined variable $fileToProcess in /in/2u7sD on line 6 Deprecated: basename(): Passing null to parameter #1 ($path) of type string is deprecated in /in/2u7sD on line 6 string(25) "1970-01-01T01:00:00+01:00"
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Warning: Undefined variable $fileToProcess in /in/2u7sD on line 6 Deprecated: basename(): Passing null to parameter #1 ($path) of type string is deprecated in /in/2u7sD on line 6 string(25) "1970-01-01T01:00:00+01:00"
Output for 8.0.0 - 8.0.12, 8.0.14 - 8.0.30
Warning: Undefined variable $fileToProcess in /in/2u7sD on line 6 string(25) "1970-01-01T01:00:00+01:00"
Output for 8.0.13
Warning: Undefined variable $fileToProcess in /in/2u7sD on line 6 string(25) "1970-01-01T00:00:00+00:00"
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.31, 7.4.0 - 7.4.33
Notice: Undefined variable: fileToProcess in /in/2u7sD on line 6 string(25) "1970-01-01T01:00:00+01:00"
Output for 7.3.32 - 7.3.33
string(25) "1970-01-01T00:00:00+00:00"

preferences:
163.3 ms | 401 KiB | 173 Q