Home  >  Article  >  Backend Development  >  How to get file modification time in php

How to get file modification time in php

藏色散人
藏色散人Original
2020-07-08 11:24:082546browse

In PHP, you can use the filemtime function to obtain the file modification time. The function of the filemtime function is to return the last modification time of the file content. The syntax is "filemtime(filename)", where the parameter filename represents the file to be checked.

How to get file modification time in php

php gets the file modification time

In PHP, you can use the filemtime function to get the file modification time.

filemtime() function definition and usage

filemtime() function returns the last modification time of the file content.

If successful, this function will return the last modification time of the file contents in the form of a Unix timestamp. On failure, returns FALSE.

Syntax

filemtime(filename)

Parameters

filename required. Specifies the documents to be checked.

Tips and Notes

Note: The results of this function will be cached. Please use clearstatcache() to clear the cache.

Example

<?php
echo filemtime("test.txt");
echo "<br />";
echo "Last modified: ".date("F d Y H:i:s.",filemtime("test.txt"));
?>

The above code will output:

1139919766
Last modified: February 14 2006 13:22:46.

For more related knowledge, please visit PHP Chinese website!

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