What is the fileatime() function in PHP?
The fileatime() function is a built-in function in PHP. It returns the last access time of any file specified by the user.
Syntax
fileatime($filename)
$filename: The file for which we want to check the last access time.
Return value
This method returns a Unix timestamp denoting the last access time. If it fails, False is returned.
Code
Let’s look at the code to determine when hello.txt was last accessed:
main.php
hello.txt
<?php// Checking last access time of fileecho fileatime("hello.txt");echo "\n";// formatting the data in data and time formatecho "Checking last access time of file: ".date("F d Y H:i:s.",fileatime("hello.txt"));?>
Free Resources
Copyright ©2025 Educative, Inc. All rights reserved