Deriving UTC from syncTime()?

I’ve seen some other people trying to get UTC time by using NTP. Now that the firmware includes the option to sync time with the particle cloud, I’m wondering if we can derive UTC from that? I have a bad feeling that since documentation says it sets millis() and that value is known to wrap that this is not possible, but just looking for confirmation before I go the harder route.

Thanks in advance.

@chasc

I don’t really understand what you are looking for except to say that the Particle Time Library is your friend here.

Using Time.now() will return a UTC timestamp unadjusted for DST, even if you have set your DST using Time.zone()

Does that answer your question?

Regarding the comment:

You may have confused use of the Time library for use of a millis() timer, for which you can learn about here.

Wow, ok I’m a little embarrassed but I can see how I missed that. In the reference documentation TOC there is a “Time” section at the top level which only has C functions like millis() and micros(). I saw that and figured it was everything to do with time. Plus under the Particle.syncTime() reference it only uses millis(), so I didn’t find it there either.

Thanks again, glad I asked!

Hi @chasc

Glad you found the answer to your question. Cloud time-keeping is built-in and works great but if you are looking for true NTP, you could use my older SparkTime library. Check the web IDE for details.

2 Likes