PHP fileatime() Function

Definition and Usage

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 the form of Unix timestamp.

Syntax

fileatime(filename)
Parameter Description
filename Required. Specify 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. It can be very affecting the performance when an application regularly accesses a large number of files or directories. Some Unix file systems can turn off 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.