Thanks for responding. Pretty sure I've read that a number of times, and have seen only one unrelated reference to UTC. I'm looking for a bit more direction...
Time zone I currently wrote in is USA - Eastern, but my application could be in use anywhere in the world - so I need to output the local date/time in UTC.
Public Sub GetTimeZoneOffset As Int
Dim s, d As String
Dim l As Long
s = DateTime.DateFormat
DateTime.DateFormat = "MM/dd/yyyy HH:mm:ss"
l = DateTime.Now
d = DateTime.Date(l) & " GMT"
DateTime.DateFormat = "MM/dd/yyyy HH:mm:ss z"
Dim res As Int
res = -Round((l - DateTime.DateParse(d))/3600000)
DateTime.DateFormat = s
Return res
End Sub
Public Sub GetTimeZoneOffset As Int
Dim s, d As String
Dim l As Long
s = DateTime.DateFormat
DateTime.DateFormat = "MM/dd/yyyy HH:mm:ss"
l = DateTime.Now
d = DateTime.Date(l) & " GMT"
DateTime.DateFormat = "MM/dd/yyyy HH:mm:ss z"
Dim res As Int
res = -Round((l - DateTime.DateParse(d))/3600000)
DateTime.DateFormat = s
Return res
End Sub
Thanks - this is good. I'll be able to use this for real time measurements.
How could I go about converting existing date/time strings (formatted as "03/07/2015 11:11:44") to UTC - given that I know the timezone they were collected in.
This code adds the EST timezone to the original string and the prints the UTC time:
B4X:
DateTime.SetTimeZone(0) 'only need to set it once so the process is now based on UTC timezone.
DateTime.DateFormat = "MM/dd/yyyy HH:mm:ss z"
Dim ticks As Long = DateTime.DateParse("03/07/2015 11:11:44" & " EST")
Log(DateTime.Date(ticks))
I copied the code with 3600000 from somewhere and wrote the code with DateTime.TicksPerHour. The copied code is in a utilities module that I hardly ever edit (kind of a "Black-Box" chunk of code.