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();
}
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.