#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <time.h>
int main()
{
char file[100] = "d:\\data.txt";
struct stat stats;
struct tm dt;
printf("File: %s\n", file);
if (stat(file, &stats) == 0) {
dt = *(gmtime(&stats.st_ctime));
printf("Created on: %d-%d-%d %d:%d:%d", dt.tm_mday, dt.tm_mon, dt.tm_year + 1900,
dt.tm_hour, dt.tm_min, dt.tm_sec);
}
else {
printf("Unable to get file created time\n");
}
return 0;
}
/*
run:
File: d:\data.txt
Created on: 12-6-2020 7:35:3
*/