문제

I've come across a rather strange issue while building a file browser sort of app in PHP. For the purpose of this app, filemtime() is more useful to me, as I need the date of the last modification to the file's content. Unfortunately, the date returned by filemtime() see horribly wrong, being always lower than filectime(), most of the times by almost a year.

While I can conceive scenarios where this would be possible (if the file was chowned recently, but that was modified long ago). However, this is not the case, as all files were copied to the machine no more than a month and a half ago.

Code is this is simple

$mtime = date ("F d Y H:i:s.", filemtime(BASE_DIR.$target));
도움이 되었습니까?

해결책

AFAIK, this is normal. When copying files, the OS will sometimes set the creation time to the time of copying, while preserving the file's original "last modified" date.

I can't say which OSes and filesystem combinations support this, and I can't find any sources at a quick glance, but it's definitely something that I've seen happen on Windowses, OS Xes and *nixes.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top