How do I get the time that a file was created?
What I have found: The lfs library for Lua contains a method to get file attributes. However, the only ones that seem to get close to answering my question are those:
None of them, by their descriptions, check for the creation time specifically. I've been googling for a while and can't find the answer.
EDIT: I'm on a windows system.
Windows command-line provides the argument /T:C to show the file creation date/time when used in context of dir command.
So, you can use the io.popen function as follows:
local sOut = io.popen( "dir /T:C *files*", "r" )
local sData = sOut:read "*a"
-- process sData as string to filter content as your needs
At least on Unix, you can't. There are three members related to time in struct stat:
st_atime Time of last access.st_mtime Time of last data modification.st_ctime Time of last status change.Some people misunderstood st_ctime for file creation time, but that's not true. File creation time is not preserved in Unix-style system.
The closest is last status change time, which you could get with lfs library, or, read How can I get last modified timestamp in Lua for a solution without third-part libraries.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With