-->
Page 1 of 1

Littlefs how to set a specific date time for file timestamp?

PostPosted: Sun Jun 07, 2020 9:53 am
by Tertius21
I want to set a specific date and time for the file timestamp with littlefs.

I know this example from the Docs:
Code: Select alltime_t myTimeCallback() {
return 1455451200; // UNIX timestamp
}
void setup () {
LittleFS.setTimeCallback(myTimeCallback);
...
// Any files will now be made with Pris' incept date
}


But i don't understand how can i set a date in myTimeCallback e.g. 12.11.2020 1:11:23

Please can someone help me? Thanks....

Re: Littlefs how to set a specific date time for file timest

PostPosted: Sun Jun 07, 2020 10:31 am
by Pablo2048
Just search for UNIX timestamp, and learn how you can construct the date (or use some of the online tools).

Re: Littlefs how to set a specific date time for file timest

PostPosted: Sun Jun 07, 2020 12:09 pm
by Tertius21
Code: Select alltime_t myTimeCallback() {
  setTime(9, 43, 21, 7, 8, 2020);
  return now();
}


That works.