find the last accessed date of a directory in php

To get the last accessed date of a directory in PHP, you can use the fileatime() function. This function returns the last accessed time of a file or directory, in Unix timestamp format (number of seconds since January 1 1970 00:00:00 UTC).

Here's an example code snippet that demonstrates how to use fileatime() to get the last accessed date of a directory in PHP:

main.php
$dir_path = '/path/to/your/directory';

// Get the last accessed time of the directory
$last_accessed_time = fileatime($dir_path);

// Convert Unix timestamp to a human-readable date/time string
$last_accessed_date = date('Y-m-d H:i:s', $last_accessed_time);

// Output the result
echo "The directory was last accessed on: ".$last_accessed_date;
346 chars
11 lines

In this code, replace /path/to/your/directory with the actual path to your directory. The date() function is used to convert the Unix timestamp to a human-readable date/time string.

gistlibby LogSnag