How to get 'file creation time' in Linux
11,674
How do I get the date a file was last modified?.
struct stat attrib; //1. create a file attribute structure
stat("file_name", &attrib); //2. get the attributes of afile.txt
clock = gmtime(&(attrib.st_mtime)); //3. Get the last modified time and
// put it into the time structure
In Linux: three distinct timestamps associated with a file:
- time of last access of contents (
atime
),- time of last modification of contents (
mtime
),- and time of last modification of the inode (metadata,
ctime
).
So, no, you cannot find file creation time. (reference). Some useful Links related to you question:
- How do I do a ls and then sort the results by date created?
- Get file created/creation time?
- A good article, "file creation times".
Author by
user1616699
Updated on June 05, 2022Comments
-
user1616699 almost 2 years
I need to find out at what time and date a file has been created using C++ in Linux.