0
我有一个工作代码,读取一个目录并已输出name
,total files
和size
。我想要做的也是抓住Date Modified
并将其格式化为YYYY-MM-DD
。PHP的读取目录和输出日期修改为文件夹
代码:
if ($handle = opendir('D:/'.$sub.'/')) {
while (false !== ($entry = readdir($handle))) {
if ($entry != '$RECYCLE.BIN' && $entry != 'System Volume Information' && $entry != '.' && $entry != '..') {
$exists = mysql_query('SELECT * FROM comics WHERE arc LIKE "'.$entry.'%"');
$exists1 = mysql_num_rows($exists);
if ($exists1 == 0) {
$directory = $base.$sub."/".$entry;
$filecount = count(glob($directory."/"."*.*"));
$size = 0;
$d = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($directory),
RecursiveIteratorIterator::SELF_FIRST
);
foreach($d as $file){
$size += $file->getSize();
}
$entry = str_replace(" - ", ": ", $entry);
mysql_query('INSERT INTO comics (arc, files, size) VALUES ("'.$entry.'\n", "'.$filecount.'", "'.$size.'")');
print "<li>Inserted <b>".$entry."</b> With A File Count Of <b>".$filecount."</b> & A Total Size Of <b>".$size."</b> Bytes.</li>";
}
}
}
}
你可以找到答案INT这个帖子:[http://stackoverflow.com/questions/2773009/can-we-get-the- directorys改性 - 时间 - 和 - 大小 - 即-统计] [1] [1]:http://stackoverflow.com/questions/2773009/can-we-get-the-directorys-modified - 时间和大小,即-统计 – Kres 2012-03-09 14:10:03