How to retrieve correct Time for a roaming device

Hi -

I am building a device that will be used across various time Zones.

My understanding is that the device will get the time from the Handshake with Particle Cloud on my profile, is this correct? If indeed the case, the time will be wrong all of the time is it will never be used in my time zone.

Not sure and external RTC would haver solved the problem as I would need to set the time "dynamically" based on the the location.

Is this possible?

Kind Regards, Friedl.

PS: Happy new year! :champagne:

The time you get from the Particle cloud will always be UTC as the cloud has no knowledge about the position of your device.
You'd need to get some location info to determine the correct timezone and provide the apropriate time offset.

@rickkas7 has proveded a brilliant LocalTimeRK library that makes finding that offset easier.

1 Like


Thanks a million. Will look into it, with a little luck I can manage to make it work :slight_smile:

Hi Friedl,
(happy new year!)
Would it be possible for you to only use UTC time on those devices?

What I mean is this:

  • if the device does not have a local display or does not show the time to the users, use UTC all the way to the cloud or database (if there is one)
  • if the device has a display that shows the users the time, well, in this case you want to display the local time, and you need a solution like the one ScruffR proposed.


Hi @gusgonnet -

The device does have a local display but will not necessarily display the time. the problem is that the device will display certain information based on the time of day. We need to log attendance of people attending seminars and as there are multiple sessions each day, the display will show the next event information based on what time is it.

Does this make sense? :slight_smile:

Thanks!! Looking forward do doing more Particle projects this year :slight_smile:

How do you log the attendance, via the local display or using a website or mobile app?
If using a website or mobile app, maybe you can log the attendance in UTC and get rid of the timezones?

Why all the warnings? Timezones are difficult, and considering local daylight saving times is a pain. So if you can avoid all that pain, the better.

RFID and QR codes. The display is to show the information of the next event scheduled.

We retrieve all the data for the entire day from an end point provided by the client. The device then stores this data and updates the screen as needed. I need the time to determine which event is up next and update the paper display accordingly.

1 Like


Just a thought, I can ask the client to include the time zone for the specific event in the end point data correct? This I can then use to set the time zone in my application code and make the adjustment from UTC ??

yes, if they can provide the events with a time zone (or in UTC), your particle device does not need to know the time zone it is currently located in, and you save a number of headaches in your code.

1 Like

I will check with the client. Maybe we can display "Next event in 2 hours" and count down, as apposed to "Next event @ 4pm" In this case we can use UTC.

But I suspect he might want to use local times.

Thanks for the help!! :slight_smile:

Can you use an IP address geolocator service such as:

IP address location may not be 100% accurate, but close enough?

Hi @Muskie -

Thank you for the info, I will look into this as well.

Much appreciated!


@friedl_1977 - I agree with @gusgonnet, avoid using local time if at all possible. If it was me, I’d have them provide you the schedule of events in UTC time. I try and capture, record and pass time around as UTC, only at the very last moment do I convert it. In my case, I use JavaScript in the web app. I pass the data to the front end still in UTC and then JavaScript identifies all time on the screen to convert it to local based on the time zone the browser says it is.

In the one instance I can’t do that (sending it out as a SMS message). Then instead of saying last reading was at 10:00 AM, I say the last reading was 5 minutes ago. So even in that scenario, I don’t have to deal with time zone/daylight savings math complexity.


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.