Created
September 18, 2023 10:35
-
-
Save alvonx/343f892a5e7eb5a706f8866d3701685d to your computer and use it in GitHub Desktop.
get system time esp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <time.h> | |
#include <sys/time.h> | |
void setup() { | |
Serial.begin(115200); | |
delay(5000); | |
struct timeval tv; | |
tv.tv_sec = 1611198855; | |
tv.tv_usec = 0; | |
settimeofday(&tv, nullptr); | |
} | |
void loop() { | |
time_t now; | |
char buff[80]; | |
time(&now); | |
strftime(buff, sizeof(buff), "%c", localtime(&now)); | |
Serial.println(buff); | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment