mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 11:59:12 +03:00
first working version
This commit is contained in:
20
Time_esp32.ino
Normal file
20
Time_esp32.ino
Normal file
@@ -0,0 +1,20 @@
|
||||
#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
|
||||
Reference in New Issue
Block a user