Getting a File's Last Modification Time


You need to know the last time a file was modified.


Use the File::lastModified() method.

$timestamp = File::lastModified($filename);
if ($timestamp === false)
    die("Failure getting the time");

The value returned is a Unix timestamp.


If there's an error, a warning message is emitted.

It's a good idea to make sure the file exists before getting the modification time. See Determining If a File Exists.

comments powered by Disqus