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

王林
Release: 2023-03-07 09:42:02
Original
3146 people have browsed it

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)."
";
?>
Copy after login

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!

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