Introduction
This article explains Accessed and Modified Times in PHP. You will see the last access or modified file of your directory. The ability to work out a file's last access and modification time plays a crucial role in several administrative tasks, particularly in network applications that involve network or CPU intensive update operations. PHP offers 3 functions for determining a file's access, creation, and last modification time.
Syntax
| Int fileatime ( string $filename ); |
This function gets the last file access time. The filename is required to include the path of the file to get the access time. Let's get the last accessed time of the file with examples.
Example
<?php
$Accessed1 = 'C:/wamp/www/text.php';
$Accessed2 = 'C:/wamp/www/test.php';
$Accessed3 = 'C:/wamp/www/exa.php';
$Accessed4 = 'C:/wamp/www/functions.js';
$Accessed5 = 'C:/wamp/www/mins.gif';
printf("Last Accessed this file: %s", date("m-d-y g:i:sa", fileatime($Accessed1)));
echo "<br>";
printf("Last Accessed this file: %s", date("m-d-y g:i:sa", fileatime($Accessed2)));
echo "<br>";
printf("Last Accessed this file: %s", date("m-d-y g:i:sa", fileatime($Accessed3)));
echo "<br>";
printf("Last Accessed this file: %s", date("m-d-y g:i:sa", fileatime($Accessed4)));
echo "<br>";
printf("Last Accessed this file: %s", date("m-d-y g:i:sa", fileatime($Accessed5)));
?>
Output

Syntax
| Int filectime ( string $filename ); |
This function gets the last change time of the file.
Example
<?php



Join the conversation! Your thoughts help the community grow.