Skip to content

Instantly share code, notes, and snippets.

@alvonx
Created September 18, 2023 10:35
Show Gist options
  • Save alvonx/343f892a5e7eb5a706f8866d3701685d to your computer and use it in GitHub Desktop.
Save alvonx/343f892a5e7eb5a706f8866d3701685d to your computer and use it in GitHub Desktop.
get system time esp
#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