$fileName = "Backup_1486874341.tar.gz"
Here is my file name. How can i get only timestamp from that file name Like 1486874341
$fileName = "Backup_1486874341.tar.gz"
Here is my file name. How can i get only timestamp from that file name Like 1486874341
Use simple regex in preg_match()
to select target digit in file name.
$fileName = "Backup_1486874341.tar.gz";
preg_match("/_(\d+)./", $fileName, $matches);
echo $matches[1];
See result in demo
Here is the sample snippet:
<?php
$str = 'Backup_1486874341.tar.gz';
preg_match_all('!\d+!', $str, $matches);
print_r($matches[0][0]);
?>