Various times for php to read files_PHP tutorial

WBOY
Release: 2016-07-13 17:14:48
Original
760 people have browsed it

To get the modification and creation time of a file in PHP, we can directly use the filemtime() function, which can return the last modification time of the file content.

If successful, the time is returned as a Unix timestamp. On failure, returns false.

filemtime ( string filename )

Returns the time when the file was last modified, and returns FALSE if an error occurs. The time is returned as a Unix timestamp, usable with date().

The code is as follows
 代码如下 复制代码

$a=filemtime("log.txt");   

echo "修改时间:".date("Y-m-d H:i:s",$a);

Copy code


$a=filemtime("log.txt");
 代码如下 复制代码

$a=filectime("log.txt");   

echo "创建时间:".date("Y-m-d H:i:s",$a);

echo "Modification time:".date("Y-m-d H:i:s",$a);

 代码如下 复制代码

$a=fileatime("log.txt");   

echo "修改时间:".date("Y-m-d H:i:s",$a)."

filectime ( string filename ) Returns the time when the file's inode was last modified, or FALSE if an error occurs. The time is returned as a Unix timestamp.

The code is as follows Copy code
$a=filectime("log.txt");

echo "Creation time:".date("Y-m-d H:i:s",$a); fileatime ( string filename ) Returns the time the file was last accessed, or FALSE if an error occurred. The time is returned as a Unix timestamp.
The code is as follows Copy code
$a=fileatime("log.txt");
echo "Modification time:".date("Y-m-d H:i:s",$a)."
http://www.bkjia.com/PHPjc/628904.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/628904.htmlTechArticleTo get the file modification and creation time in php, we can directly use the filemtime() function, which can return the file content Last modified time. If successful, the time is in Unix timestamp format...
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!