LittleFS and setting timestamp with new files & directories

arjen1
Posts: 8
Joined: Sun Aug 06, 2023 4:48 pm

LittleFS and setting timestamp with new files & directories

Postby arjen1 » Wed Mar 27, 2024 5:53 pm

Dear forum

Got a really hard time figuring this out.

Setup is an ESP8266 with NO internet connection.
It serves a webserver with a lot of javascript.

At start I 'get' the date/time from the client and store it in the ESP. It will show the right date.
At some point I do a httprequest to make a new directory. This will all work but the timestamp is always 1-1-1970.

I tried several things, but I am at a loss now. It appears the timestamp from now() in the esp is in seconds while the timestamp from JavaScript is in milliseconds. Pretty confusing.

Can someone direct me to an example? I could go from there.

some snippets:

Code: Select all

    Serial.printf("getall paramsnr %i\n", paramsNr);
    for(i=0;i<paramsNr;i++){
      AsyncWebParameter* p = request->getParam(i);
      today_esp[i] = p->value().toInt();
      Serial.printf("%u ", today_esp[i]);
    }
    Serial.println();
    Serial.print(now());
    Serial.print("\n");

    setTime(12,00,00,today_esp[2],today_esp[1],today_esp[0]);

Code: Select all

time_t myTimeCallback() {
//  setTime(9, 43, 21, 7, 8, 2020);
  Serial.printf("mytimecallback NOW = %llu\n"+now());
  return now();
}
In the last snippet I never get a serial.print output.

I can (and do) send an xmlrequest from kavascript to the ESP with the current date (number form 1-1-1970) is it simply possible to use that to set the timestamp on a new directory.

Why is this so hard to grasp... Sigh.
Thanks.

Who is online

Users browsing this forum: No registered users and 62 guests