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

王林
王林Original
2020-08-14 15:08:292556browse

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.

How to get the last modification time of a file in php

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 = &#39;somefile.txt&#39;;
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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn