settimeofday_cb(time_is_set); // This function gets called every time the time is set
// Part of function that handles the javascript derived seconds since epoch
else if (server.argName(i) == "synctime") {
char buff[20];
server.arg("synctime").toCharArray(buff, sizeof(buff) - 1);
Serial.print("Time sent from browser: "); Serial.println(buff);
time_t rtc = (uint32_t)buff;
timeval tv = { rtc, 0 };
settimeofday(&tv, nullptr);
}
void time_is_set(bool from_sntp) {
lastTimeSet = time(nullptr);
if (from_sntp) {
strcpy(whoSetTime, "SNTP");
}
else {
strcpy(whoSetTime, "USER");
}
Serial.println((uint32_t)lastTimeSet);
Serial.print(F("Time was set by ")); Serial.print(whoSetTime); Serial.print(F(" @ ")); Serial.println(ctime(&lastTimeSet));
}
The following is what gets sent to the Serial monitor.
Time sent from browser: 1637587376
1073741408
Time was set by USER @ Sat Jan 10 13:30:08 2004
Am I just converting the value wrong? Ive tried converting the number to all types of variables.
Any help is appreciated. Thanks for looking.