Reputation: 144
There is a nightmare i am leaving these days. And it is the DateTimes in android and the Web services
I have a WCF webservice located in a -5:00 UTC time zone and i develop an app for multi time zones
How can i handle my users datetimes so it appears correct on everyone + there is search feature by a specific datetime in the app
What is the best way to store datetimes in the database so i can handle this problem
*Note: wcf datetime format from json is "Date (1420088400000-0500)"
The datetime in my db is 2015-1-1 03:00:00
where the above format without the "-0500" gives me a 2015-1-1 08:00:00
Thanks in advance
Upvotes: 1
Views: 360
Reputation: 4549
keep the DateTime
same all over the place for the application as -5:00 UTC.
But show the user DateTime
after using the offset of the local time.
For Example.
I guy sends an message from India
at 9 am to a friend in Japan
( Japan
leads India
by 3 hours 30 minutes) so the app will add the Offset for the local time and the guy in Japan
will get the text at 12:30 in afternoon, so it will be relevant for both the people with their timezone although they are following GMT which is mutual between them.
Save the timeStamp on your database and use the local time offset before showing it to the user...
Upvotes: 1