PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

filectime> <file
Last updated: Mon, 26 Nov 2007

view this page in

fileatime

(PHP 4, PHP 5)

fileatime — 取得文件的上次访问时间

说明

int fileatime ( string $filename )

返回文件上次被访问的时间,如果出错则返回 FALSE。时间以 Unix 时间戳的方式返回。

注意:一个文件的 atime 应该在不论何时读取了此文件中的数据块时被更改。当一个应用程序定期访问大量文件或目录时很影响性能。有些 Unix 文件系统可以在加载时关闭 atime 的更新以提高这类程序的性能。USENET 新闻组假脱机是一个常见的例子。在这种文件系统下本函数没有用处。

Note: 本函数的结果会被缓存。更多信息参见 clearstatcache()

Tip

PHP 5.0.0 起本函数也可被某些 URL wrapper 使用。参考支持的协议/封装协议列表 来看哪些 wrapper 支持 stat() 系列函数的功能。

Example#1 fileatime() 例子

<?php

// 输出类似:somefile.txt was last accessed: December 29 2002 22:16:23.

$filename 'somefile.txt';
if (
file_exists($filename)) {
    echo 
"$filename was last accessed: " date("F d Y H:i:s."fileatime($filename));
}

?>

参见 filemtime()fileinode()date()



add a note add a note User Contributed Notes
fileatime
Maulwurf
11-Oct-2004 12:12
Using this function on Win98 made me grow grey hair.
Win 98 doesn't save the time for the last access. It only saves the date. This way, the returned timestamp from fileatime(file) is always much too small.

this command will always return false:

if($now - $last_access >1800) {
do something
}

using filemtime() instead did the thing.

filectime> <file
Last updated: Mon, 26 Nov 2007
 
 
show source | credits | sitemap | contact | advertising | mirror sites