龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > php编程 >

php获得文件的更新时间

时间:2014-06-19 02:15来源:网络整理 作者:网络 点击:
分享到:
php获得文件的更新时间 ```php/* * @param string $file Filepath * @param string $format dateformat * @link http://www.php.net/manual/de/function.date.php * @link http://www.php.net/manual/de/function.filemtime.php
/*
 * @param string $file Filepath
 * @param string $format dateformat
 * @link http://www.php.net/manual/de/function.date.php
 * @link http://www.php.net/manual/de/function.filemtime.php
 * @return string|bool Date or Boolean
 */
function getFiledate($file, $format) {
       if (is_file($file)) {
          $filePath = $file;
          if (!realpath($filePath)) {
                 $filePath = $_SERVER["DOCUMENT_ROOT"].$filePath;
          }
          $fileDate = filemtime($filePath);
          if ($fileDate) {
                 $fileDate = date("$format",$fileDate);
                 return $fileDate;
          }
          return false;
       }
       return false;
}
精彩图集

赞助商链接