Closed edent closed 1 year ago
My Watchy has synced with NTP and is displaying the correct time. Is there any way I can retrieve the Unix Timestamp from the device?
I've tried:
struct timeval tv; time_t curtime; gettimeofday(&tv, NULL); curtime=tv.tv_sec; display.println(curtime);
But that just displays 1 - and thereafter the seconds since the watch rebooted.
1
Someone on Discord suggested using RTC.rtc_ds.get() but that just displays 0.
RTC.rtc_ds.get()
0
I can't see anything useful in currentTime.
currentTime
Is it possible to get the current Unix timestamp?
For those looking for the answer:
RTC.read(currentTime); time_t epoch = makeTime(currentTime);
That gets you the number of seconds since the Unix Epoch.
My Watchy has synced with NTP and is displaying the correct time. Is there any way I can retrieve the Unix Timestamp from the device?
I've tried:
But that just displays
1
- and thereafter the seconds since the watch rebooted.Someone on Discord suggested using
RTC.rtc_ds.get()
but that just displays0
.I can't see anything useful in
currentTime
.Is it possible to get the current Unix timestamp?