1

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

Ahmed Hashem
  • 145
  • 2
  • 8
  • 1
    check this http://stackoverflow.com/questions/34272619/convert-net-date-to-java-date/34275049#34275049 – Pankaj Nimgade Jan 13 '16 at 18:23
  • 1
    Check my answer on this post. [WCF Json Date Serialize on Java](http://stackoverflow.com/a/30929414/3158594) – Joma Jul 07 '16 at 22:14

1 Answers1

1

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...

Pankaj Nimgade
  • 4,529
  • 3
  • 20
  • 30
  • so i send a utc time then it will be stored in the db as utc and when i receive it back from the WC i ill get it with the -5:00 tz but i will convert it to a utc then i add my tz to it (user`s tz). ill try it – Ahmed Hashem Jan 13 '16 at 20:05
  • @AhmedNTS, you are welcome, I am glad, that I could help :) – Pankaj Nimgade Jan 14 '16 at 03:47