fileatime()
fileatime() — Gets last access time of file.
Built-in function of PHP 8.5. The manual lists it as available in PHP 4, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
Signature
fileatime(string $filename): int|false
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $filename | string | Path to the file. |
Return value
Returns the time the file was last accessed, or false on failure. The time is returned as a Unix timestamp.
Example
A runnable snippet:
// outputs e.g. 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)); }
See also
filemtime(), fileinode(), date()
All PHP 8.5 built-in functions
Reference card built from the PHP manual page fileatime() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.