PHP is easy to get to the mtime of a folder, you can use the Filemtime function. But the Filemtime for the folder is due to Linux. When a file is modified, it only affects his current folder Mtime changes. Does not continue to affect folders at the top of the folder. So it might be different from the last modification of the folder you really want.
Look at the results on the Linux machine as follows, you can see the yoyotmp mtime is less than yoyotmp/test mtime.
[Root@localhost test]# ls-ld--full-time/yoyotmp/
Drwxr-xr-x. 4 Root 2015-12-01 21:09:47.526804049 +0800/yoyotmp/
[Root@localhost test]# ls-ld--full-time/yoyotmp/test
Drwxr-xr-x. 2 root 2015-12-01 21:15:22.266131826 +0800/yoyotmp/test
You can also use the Stat Folder command to view information such as Mtime
Google learned that a phper implemented the following text link:
function Dirmtime ($directory) {
1. An array to hold the files.
$last _modified_time = 0;
2. Getting a handler to the specified directory
$handler = Opendir ($directory);
//3. Looping through every content of directory
while ($file = Readdir ($handler)) {
//3.1 Checking If $file is not a directory
if (Is_file ($directory. Directory_separator. $file)) {
$files [] = $ Directory. Directory_separator. $file;
$filemtime = Filemtime ($directory. Directory_separator. $file);
if ($filemtime > $last _modified_time) {
$last _modified_ Time = $filemtime;
}
}
}
4. Closing the handle
Closedir ($handler);
5. Returning the last modified time
return $last _modified_time;
}
Example
This is example demonstrates the last modified of the directory, where the working PHP script file resides, and print to the screen.
Php. Print the last Modified time of current Directory?
$directory = DirName (__file__);
$dir _last_modified_time = Dirmtime ($directory);
echo Date (' d M Y h:i:s ', $dir _last_modified_time);