/*
* @param string $file Filepath
* @param string $format dateformat
* @link http://www.php.net/manual/de/function.date.php
* @link http://www.php.net/manual/de/function.filemtime.php
* @return string|bool Date or Boolean
*/
function getFiledate($file, $format) {
if (is_file($file)) {
$filePath = $file;
if (!realpath($filePath)) {
$filePath = $_SERVER["DOCUMENT_ROOT"].$filePath;
}
$fileDate = filemtime($filePath);
if ($fileDate) {
$fileDate = date("$format",$fileDate);
return $fileDate;
}
return false;
}
return false;
}
Get File Last Updated Date
Chris Coyier
on
Nice little helpful function. Thank you for sharing.
Just to let you know that I modified your function to check if the file date is within a given date interval:
Whops my fault, I’m posting the method again after turning < into <