php读取文件夹的目录和输出日期已修改


php read directory and output date modified for folder

我有一个工作代码,它读取目录并已经输出nametotal filessize。我想做的是获取Date Modified并将其格式化为YYYY-MM-DD

代码:

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>";
            }
        }
    }
}
if (file_exists($filename)) {
    echo "$filename was last modified: " . date ("Y-m-d", filemtime($filename));
}

http://php.net/manual/en/function.filemtime.php