When you choose a file in Finder and hit cmd+i on a Mac, you get the time the file was (actually) created, and the time it was last modified.
My question is simply: How can I get the actual time of creation from an already existing Mac file with PHP?
Now, having researched the topic, I have read posts that say it is impossible, but in my world “impossible” only means that a thing takes a bit longer to accomplish. Workarounds and hacks are welcomed.
I do not want mtime or ctime related advice, as these only access the last time the file was updated or modified.
Also we’re probably talking Mac only here, but OS independent solutions are also welcome – if they really work on all systems.
This script is the best I’ve managed, which wraps the command-line
stattool available on BSD to come up with the inode birthtime attribute.The command-line
stattool reads atime, ctime, mtime exactly like PHP’s stat, but comes up with a fourth “inode birth time” parameter. The BSDstat()system call returns st_birthtime when available, but I haven’t found a way to natively expose this to PHP.The following command returns a unix timestamp of only the inode birthtime, which is the best I’ve found so far. You can run it with popen() or proc_open()