PHP Fileatime () Function

PHP

The file name is passed as a parameter to the fileatime() function. The result of the fileatime() function is cached, and the clearstatcache() function is used to clear the cache.Syntax:
fileatime ($filename)
Parameters:The fileatime() function in PHP takes only one parameter, $filename. It specifies the file whose last access you want to check.Return Value:Returns the last access time of the file as a Unix timestamp on success and False on error. Errors and Exceptions :
  • Time resolution may vary on different file systems.
  • This feature does not work on some Unix systems that have access time updates disabled to improve performance.
  • Examples :
    Input: echo fileatime ("gfg.txt"); Output: 1525159574 Input: echo "Last accessed:" .date ("F d YH: i: s.", Fileatime ("gfg.txt")); Output: Last accessed: May 1 2018 07:26:14.
    The programs below illustrate the fileatime() function.Program 1 :  
    // check the time of the last access to the file echo fileatime ( "gfg.txt" );  
    ?>
    Output:
    1525159574
    Program 2 :  
    // check the last time the file was accessed echo fileatime ( "gfg.txt" );  
    // check the time of the last file access
    // and formatting the date output echo "Last accessed: " . date ( "F d YH: i: s." , fileatime ( "gfg.txt" )); ?>
    Output:
    1525159574 Last accessed : May 1 2018 07:26:14.
    Link:
    http://php.net/ manual / en / function.fileatime.php



    Get Solution for free from DataCamp guru