Android Question Help with Timezones

Inman

Well-Known Member
Licensed User
Longtime User
Here is what I am trying to do. I need the ticks value of time 18:30:00 of timezone GMT of the day the user runs the app, irrespective of his timezone. The day is important. Suppose a user is on GMT+5.5 timezone. If he runs the app when the time is 01:30 AM on his phone on May 13th, the system will return the date as May 13th. But GMT is still on May 12th. So the app should return the tick value of 18:30:00 GMT on May 12th. But if the same user runs at 10:30 AM on his phone, both him and GMT are on the same date and so the app should get the tick value of 18:30:00 GMT of that date.

I have been trying to get this to work since yesterday and now I am almost down with headache :( I tried different logics to generate ticks and then verified them using Epoch Converter but I never got the correct value. Please help.
 

Inman

Well-Known Member
Licensed User
Longtime User
Ha, that was simple. I always started with DateTime.SetTimeZone(-DateTime.TimeZoneOffset) thinking that will bring it to GMT. No wonder I got it wrong.

Thanks Erel.
 
Upvote 0
Top