Home > Article > Backend Development > How to get the last modification time of a file in php
How to get the last modification time of a file in php: You can use the filemtime() function to get it. The filemtime() function is used to return the time when the data block in the file was last written, that is, the time when the content of the file was last modified. If it fails, it returns false.
The filemtime() function returns the time when the data block in the file was last written, that is, the time when the content of the file was last modified. Or return FALSE on failure. The time is returned as a Unix timestamp.
(Recommended tutorial: php graphic tutorial)
Grammar:
filemtime ( string $filename )
(Recommended video tutorial: php video tutorial )
Example:
<?php $filename = 'somefile.txt'; if (file_exists($filename)) { echo "$filename was last modified: " . date ("F d Y H:i:s.", filemtime($filename)); } ?>
The above is the detailed content of How to get the last modification time of a file in php. For more information, please follow other related articles on the PHP Chinese website!