How to get the file modification time in php?

青灯夜游
Release: 2023-03-06 20:56:02
Original
3728 people have browsed it

Obtaining method: 1. Use the filemtime() function to return the last time the file content was modified. The syntax format is "filemtime(file);"; 2. Use the filectime() function to return the last time the file content was modified. The time when file permissions, owners, etc. were modified, the syntax format is "filectime(file);".

How to get the file modification time in php?

Recommendation: "PHP Video Tutorial"

#php method to get file modification time

Method 1: Use the php filemtime() function

The 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, which can be used with date(). On failure, returns FALSE.

Syntax

filemtime(filename)
Copy after login
  • filename: required. Specifies the documents to be checked.

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

Example:

Copy after login

Method 2: Use php filectime() function

filectime() function returns the specified file 's last modification time.

This function will check the daily modification of the file and the inode modification. Inode modification refers to: modification of permissions, modification of owner, modification of user group or modification of other metadata.

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

Syntax

filectime(filename)
Copy after login
  • filename Required. Specifies the documents to be checked.

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

Tip: Please use the filemtime() function to return the time when the file content was last modified.

Example:

Copy after login

The above code will output:

上一次更改的时间: January 30 2020 09:26:32.
Copy after login

Related recommendations:php training

The above is the detailed content of How to get the file modification time 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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!