Home >Backend Development >PHP Problem >How to get the latest modification time of a file in php
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)".
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); ?>
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)); ?>
We open the properties panel of index.phpd and see if the modification time is correct:
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!