Home >Backend Development >PHP Problem >How to get the modification time of a file in php

How to get the modification time of a file in php

王林
王林Original
2020-11-04 17:17:583140browse

How to get the modification time of a file in php: You can use the filectime() function to get the inode modification time of the specified file, such as [filectime("log.txt")]. If we want to get the modification time of the file content, we can use the filemtime() function to achieve this.

How to get the modification time of a file in php

Related functions:

filectime() function returns the last inode modification time of the specified file.

(Related learning video recommendations: java course)

This function returns the last time the inode of the file was modified. Returns false if an error occurs. The time is returned as a Unix timestamp.

The filemtime() function returns the last modification time of the file content. If successful, the time is returned as a Unix timestamp. On failure, returns false.

fileatime() function returns the last access time of the specified file.

This function returns the time when the file was last accessed. Returns false if an error occurs. The time is returned as a Unix timestamp.

Code sample:

< ?php
$a=filectime("log.txt");
echo "创建时间:".date("Y-m-d H:i:s",$a)."
";
$a=filemtime("log.txt");
echo "修改时间:".date("Y-m-d H:i:s",$a)."
";
$a=fileatime("log.txt");
echo "访问时间:".date("Y-m-d",$a)."
";
?>

Related recommendations: php training

The above is the detailed content of How to get the 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