Skip to content
Advertisement

PHP: how can I get file creation date?

I am reading a folder with lots of files.

How can I get the creation date of a file. I don’t see any direct function to get it.

There are filemtime and filectime.

And if the file hasn’t been modified, what will happen?

Advertisement

Answer

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

Note also that in some Unix texts the ctime of a file is referred to as being the creation time of the file. This is wrong. There is no creation time for Unix files in most Unix filesystems.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement