How to fire event trigger on all devices at the same time regardless of time zone

If my app fires an event at 9PM EST, it should also trigger that event at 6PM PST.

I am currently parsing a feed and this feed says the event will run on 9

pm EST. Without changing the feed, what is the best way to make my code universal for everyone who opens the application in any time zone.

+3


source to share


3 answers


You always store dates as UTC time (with the timezone stored separately). Then all alarm devices can easily convert them to their local time and make an alarm at the appropriate time.



Alarms that should be at 9am, no matter what timezone will be saved without a timezone.

+2


source


You can get the current timezone of the device like this:

TimeZone.getDefault()

      



.... and then convert the current device time and feed time to GMT.

Now you have to check if they are equal.

+2


source


use TimeToNow with prettytime http://www.ocpsoft.org/prettytime/

it will give you a result like 4 hours ago or a minute ago which will remove the timezone factors

0


source







All Articles