filemtime

(PHP 3, PHP 4, PHP 5)

filemtime -- 取得檔案修改時間

說明

int filemtime ( string filename )

返回檔案上次被修改的時間,出錯時返回 FALSE。時間以 Unix 時間戳的模式返回,可用於 date()

注: 本函數的結果會被暫存。更多訊息參見 clearstatcache()

提示: PHP 5.0.0 起本函數也可被某些 URL wrapper 使用。參考附錄 M 來看哪些 wrapper 支援 stat() 系列函數的功能。

本函數返回檔案中的資料塊上次被寫入的時間,也就是說,檔案的內容上次被修改的時間。

例子 1. filemtime() 例子

<?php
// outputs e.g.  somefile.txt was last modified: December 29 2002 22:16:23.
$filename 'somefile.txt';
if (
file_exists($filename)) {
    echo 
"$filename was last modified: " date ("F d Y H:i:s."filemtime($filename));

}
?>

參見 filectime()stat()touch()getlastmod()