Parsing File's timestamp on a SD card
Posted: Fri Nov 03, 2017 11:45 am
Hi esp-idf,
I'd to know how to get the "UTC Time" from the timestamp that I got from a file I got on my SD card.
I've try to setup my local timezone as "Europe/Berlin", then deploy localtime() and gmtime() to read/parse the timestamp from a file on SD card. But the result is the same value, which is what I can read from my Windows machine.
Here is the code Snippet:
best regards
Gfast2
I'd to know how to get the "UTC Time" from the timestamp that I got from a file I got on my SD card.
I've try to setup my local timezone as "Europe/Berlin", then deploy localtime() and gmtime() to read/parse the timestamp from a file on SD card. But the result is the same value, which is what I can read from my Windows machine.
Here is the code Snippet:
Code: Select all
// read the file timestamp
setenv("TZ", "Europe/Berlin", 1);
tzset();
struct stat attrib;
stat(fToRead, &attrib);
char fileTime[50];
// strftime(fileTime, 50, "%Y-%m-%d %H:%M:%S", localtime(&attrib.st_mtime)); // Both function through out the same output.
strftime(fileTime, 50, "%Y-%m-%d %H:%M:%S", gmtime(&attrib.st_mtime));
Gfast2