php很容易获取到一个文件夹的mtime,可以使用filemtime函数。但文件夹的filemtime由于linux的原因。文件修改时,只会影响他当前的文件夹mtime变化。并不会继续影响文件夹上层的文件夹。所以可能跟真正想得到的文件夹的最后修改时间不同。
看linux机器上的效果如下, 可以看到yoyoTmp的mtime小于yoyoTmp/test的mtime。
[root@localhost test]# ls -ld --full-time /yoyoTmp/
drwxr-xr-x. 4 root root 34 2015-12-01 21:09:47.526804049 +0800 /yoyoTmp/
[root@localhost test]# ls -ld --full-time /yoyoTmp/test
drwxr-xr-x. 2 root root 20 2015-12-01 21:15:22.266131826 +0800 /yoyoTmp/test
也可使用stat 文件夹命令查看mtime之类信息
google得知一个phper实现了如下 原文链接:
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 the 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 example demonstrates how to find the last modified time of the directory, where the working PHP script file resides, and print the result 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);
敢达决战官方正版 安卓版v6.7.9
下载敢达决战 安卓版v6.7.9
下载像素火影骨架佐助 (Perseverance Fire Shadow)手机版v1.16
下载要塞英雄 安卓版v33.20.0-39082670-Android
下载梦想城镇vivo最新版本 安卓版v12.0.1
梦想城镇vivo版是这款卡通风模拟经营类手游的渠道服版本,玩
怦然心动的瞬间 安卓版v1.0
怦然心动的瞬间是一款真人向的恋爱互动游戏,在游戏中玩家将扮演
曼尼汉堡店游戏 安卓版v1.0.3
曼尼汉堡店是一款非常好玩的精品恐怖类型冒险游戏,在这款游戏中
现代总统模拟器去广告版 安卓版v1.0.46
现代总统模拟器是一款休闲养成类游戏,可能对于不少的玩家来说都
现代总统模拟器付费完整版 安卓版v1.0.46
现代总统模拟器高级版在商店是需要付费的,相对于普通版本,高级