Skip to content
Michael Miller edited this page Dec 27, 2016 · 2 revisions

How do I set the time from NTP Server or with a Epoch time?

The time from a NTP Server is the seconds since Jan 1st, 1900.
Epoch time is seconds since Jan 1st, 1970.

First convert your NTP time to Epoch time.

This Sketch demonstrates getting the NTP time from a server and converting it to Epoch time.

With an Epoch time initialize RtcDateTime with it and set it on the RTC object.

RtcDateTime timeToSet;

timeToSet.InitWithEpoch32Time(myEpochTimeValue);
rtcObject.SetDateTime(timeToSet);
Clone this wiki locally