I Inman Well-Known Member Licensed User Longtime User May 13, 2014 #1 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.
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.
Erel B4X founder Staff member Licensed User Longtime User May 13, 2014 #2 If I understand the requirements correctly then it should be enough to set the time zone to 0 (DateTime.SetTimeZone) and call DateTime.TimeParse("18:30:00"). Upvote 0
If I understand the requirements correctly then it should be enough to set the time zone to 0 (DateTime.SetTimeZone) and call DateTime.TimeParse("18:30:00").
I Inman Well-Known Member Licensed User Longtime User May 13, 2014 #3 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
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.