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

王林
Release: 2023-03-04 13:22:01
Original
2548 people have browsed it

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 )
Copy after login

(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));
}
?>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template