PHP fileatime() Function

Definition and Usage

The fileatime() function returns the last access time of the specified file.

This function returns the last access time of the file. If an error occurs, it returns false. The time is returned in Unix timestamp format.

Syntax

fileatime(filename)
Parameter Description
filename Required. Specifies the file to be checked.

Tips and Comments

Tip:The result of this function will be cached. Please use clearstatcache() To clear the cache.

Note:The atime of the file should be changed whenever the data block in the file is read. When an application regularly accesses a large number of files or directories, it can affect performance. Some Unix file systems can disable atime updates at load time to improve the performance of such programs. USENET news group offline is a common example. Under this file system, this function is not useful.

Example

<?php
echo fileatime("test.txt");
echo "Last access: ".date("F d Y H:i:s.",fileatime("test.txt"));
?>

Output:

1140684501
Last access: February 23 2006 09:48:21.