Home > Article > Backend Development > php filemtime - Get file modification time_PHP tutorial
php filemtime - Get file modification time
filemtime
(PHP 4, PHP 5)
filemtime - Get file modification time
Description
international filemtime (string $filename)
This function returns when the data block of the file is written, which is when the contents of the file changed.
Parameters
File name
File path.
Return value
Returns the time the file was last modified, or FALSE in case an error occurs. The time returned is as a Unix timestamp, which is suitable for the date() function.
Example
Example #1 filemtime() example
// outputs e.g. somefile.txt was last modified: December 29 2002 22:16:23.
$filename = 'somefile.txt';
if (file_exists($filename)) {
echo "$filename was last modified: " . date ("F d Y H:i:s.", filemtime($filename));
}
?>