How to get the last modification time of a file in PHP?

Guanhui
Release: 2023-03-03 06:38:01
Original
3001 people have browsed it

How to get the last modification time of a file in PHP?

#How to get the last modification time of a file in PHP?

In PHP, you can easily obtain the last modification time of a file through the system's own function "filemtime()". Its function is to return the time when the file was last modified. An error occurs. Returns FALSE.

<?php
$a=filemtime("log.txt");
echo "修改时间:".date("Y-m-d H:i:s",$a)."
?>
Copy after login

Knowledge Extension

filemtime ( string filename )
Copy after login

Returns the time when the file was last modified, and returns FALSE on error. The time is returned as a Unix timestamp, usable with date().

For example:

$a=filemtime("log.txt");
echo "修改时间:".date("Y-m-d H:i:s",$a)."
Copy after login

---------------------------------- -----------------------------------------------

filectime ( string filename )
Copy after login

Returns the time when the file's last inode was modified, or FALSE if an error occurs. The time is returned as a Unix timestamp.

For example:

$a=filectime("log.txt");
          echo "创建时间:".date("Y-m-d H:i:s",$a)."
Copy after login

---------------------------------- -----------------------------------------------

fileatime ( string filename )
Copy after login

Returns the time when the file was last accessed, or FALSE if an error occurred. The time is returned as a Unix timestamp.

For example:

$a=fileatime("log.txt");
echo "修改时间:".date("Y-m-d H:i:s",$a)."
Copy after login

Recommended tutorial: "PHP"

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:
php
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