Home  >  Article  >  Backend Development  >  linux - php uses the filectime function to get the modification time of the file and returns 1970

linux - php uses the filectime function to get the modification time of the file and returns 1970

WBOY
WBOYOriginal
2016-12-01 01:27:402358browse

Environment: CentOS6.5
Use php to get the modification time of the file. The result is 1970. Why is this?
Code:

<code>$handler=opendir(dirname(__FILE__)."/uploadfiles/down");
while($file=readdir($handler)){
    if($file=="." || $file==".."){
        continue;
    }
    echo $file.'-'.date('Y-m-d H:i:s',filectime($file)).'<br/>';
}</code>

Result:

linux - php uses the filectime function to get the modification time of the file and returns 1970

But the time of . and .. is normal, I don’t understand

Thank you everyone

Reply content:

Environment: CentOS6.5
Use php to get the modification time of the file. The result is 1970. Why is this?
Code:

<code>$handler=opendir(dirname(__FILE__)."/uploadfiles/down");
while($file=readdir($handler)){
    if($file=="." || $file==".."){
        continue;
    }
    echo $file.'-'.date('Y-m-d H:i:s',filectime($file)).'<br/>';
}</code>

Result:

linux - php uses the filectime function to get the modification time of the file and returns 1970

But the time of . and .. is normal, I don’t understand

Thank you everyone

Use filemtime() to get the last modification time of the file content. The filectime() you use is used to get the last inode modification time of the file.

Path problem...my IQ

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn