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

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

青灯夜游
Release: 2023-03-15 11:52:02
Original
2794 people have browsed it

In PHP, you can use the filemtime() function to get the latest modification time of the file. The function of this function is to get and return the last modification time of the file (in the form of timestamp). The syntax "filemtime(to be checked) file path)".

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

The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

In PHP, you can use the filemtime() function to get the latest modification time of the file.

The filemtime() function returns the last modification time of the file content; if successful, the function will return the last modification time of the file content in the form of a Unix timestamp. On failure, returns FALSE.

<?php
header("Content-type:text/html;charset=utf-8");
$file = "index.php";
echo "最后的修改时间:".filemtime($file);
?>
Copy after login

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

Because the filemtime() function returns the modification time in the form of a timestamp, we can use the date() function to format it into a readable time format.

<?php
header("Content-type:text/html;charset=utf-8");
$file = "index.php";
echo "最后的修改时间:".date("Y-m-d H:i:s",filemtime($file));
?>
Copy after login

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

We open the properties panel of index.phpd and see if the modification time is correct:

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

ok, yes Yes.

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to get the latest modification time of a file in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template