I use the nodemcu ESP8266. I am currently working on a clock. So far, I had been sure, I would need to get the time from the internet. I did this using the worldtimeapi and it worked. Just for fun, I wanted to see what would happen if I used chrono (std::chrono). So I tried this code:
const auto now = std::chrono::system_clock::now();
const std::time_t t_c = std::chrono::system_clock::to_time_t(now);
tft.setCursor(0, 0);
tft.printf("The system clock is currently at %s", std::ctime(&t_c));
To my surprise, it gave me the correct time with a unix offset of zero. Can anyone explain to me how this is possible? It seems unlikely to me, that the arduino has a clock inside of it that's running at all times. The idea of chrono getting the time from the internet itself also seems weird, as the documentation clearly says, it returns the SYSTEM time. Lastly, it's unlikely that it gets the time from the PC it's connected to since the same C++ code on my PC returns the time with a unix offset of +2.
How does chrono on the esp8266 get the current unix timestamp?