PHP fileatime() Function
In this chapter you will learn:
- Definition for PHP fileatime() Function
- Syntax for PHP fileatime() Function
- Parameter for PHP fileatime() Function
- Note for PHP fileatime() Function
- Return for Is Required
- Example - Get last accessed time.
Definition
The fileatime() function returns the last access time of the specified file.
Syntax
PHP fileatime() Function has the following syntax.
fileatime(filename)
Parameter
Parameter | Is Required | Description |
---|---|---|
filename | Required. | File to check |
Note
The result of this function are cached. Use clearstatcache() to clear the cache.
Return
Returns the time the file was last accessed, or FALSE on failure. The time is returned as a Unix timestamp.
Example
PHP function fileatime() returns last accessed time.
It returns a Unix timestamp for the time, which you then need to convert using a call to date(), like this:
<?PHP// j av a 2 s . com
$contacts = "text.txt";
$atime = fileatime($contacts);
$mtime = filemtime($contacts);
$atime_str = date("F jS Y H:i:s", $atime);
$mtime_str = date("F jS Y H:i:s", $mtime);
print "File last accessed: $atime_str\n";
print "File last modified: $mtime_str\n";
echo fileatime("test.txt");
echo "\n";
echo "Last access: ".date("F d Y H:i:s.",fileatime("test.txt"));
?>
Next chapter...
What you will learn in the next chapter:
- Definition for PHP filectime() Function
- Syntax for PHP filectime() Function
- Parameter for PHP filectime() Function
- Note for PHP filectime() Function
- Return for PHP filectime() Function
- Example - Get the last change time for a file
Home » PHP Tutorial » PHP File Functions