Home > Article > Backend Development > linux - php uses the filectime function to get the modification time of the file and returns 1970
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:
But the time of . and .. is normal, I don’t understand
Thank you everyone
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:
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