PHP: how can I get the file creation date?

I am reading a folder with a lot of files.

How can I get the file creation date. I do not see any direct function to receive it.

There are filemtime and filectime .

And if the file has not been modified, what will happen?

+55
file php
Dec 09 '10 at 17:38
source share
3 answers

Use filectime . For Windows, it will return the creation time, and for Unix, it will return the change time that you can best get, because on Unix there is no creation time (on most file systems).

Note also that in some Unix texts a ctime of a file is called being a file creation time. This is not true. There is no creation time for Unix files on most Unix file systems.

+67
Dec 09 '10 at 17:44
source share

Unfortunately, if you are working on Linux, you cannot access this information, since only the last modified date is saved.

It depends a little on your file system. I know that ext2 and ext3 do not support creation time, but I think ext4 does.

+5
Dec 09 2018-10-09
source share

There is a solution for Mac OS X that supports date creation date in its file system: How to get the actual file creation time in PHP on Mac?

+1
Jun 09 '15 at 15:30
source share



All Articles