Files
IoTManager/Time_esp32.ino
2019-12-24 11:53:26 +03:00

21 lines
357 B
C++

#ifdef ESP32
void Time_Init() {
//init and get the time
configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);
printLocalTime();
}
void printLocalTime() {
struct tm timeinfo;
if (!getLocalTime(&timeinfo)) {
Serial.println("[E] Failed to obtain time");
return;
}
Serial.println(&timeinfo, "[V] %A, %B %d %Y %H:%M:%S");
}
#endif