Computer >> Computer tutorials >  >> Programming >> PHP

fileatime() function in PHP


The fileatime() function returns the last access time of a file. It returns the last accessed time of a file as a UNIX timestamp. it returns false on failure.

Syntax

fileatime ( file_path );

Parameters

  • file_path − The path of the file for which the last access time will be found.

Return

The fileatime() function returns the last accessed time of a file as a UNIX timestamp. it returns false on failure.

Example

<?php
   echo fileatime("new.txt");
?>

Output

1315416291

Let us now get the last access time as a date which is in human readable form.

Example

<?php
   echo "Last access time of the file: ".date("F d Y H:i:s.",fileatime("new.txt"));
?>

Output

Last access time of the file: September 22 2018 11:23:52