I am running out of ways to covert an SQLDateTime retrieved from a database from the local time zone where it was recorded to UTC. I am trying to do this with DateTime but thinking the old Date or Xojo.Core.Date might be easier.
Perhaps something like this:
Var date1 As DateTime = New DateTime(2021, 2, 1, 13, 0, 0, 0, TimeZone.Current) Var gmt As New TimeZone(0) // Get GMT time zone Var gmtDate As New DateTime(date1.SecondsFrom1970, gmt)
It seems that DateTime.FromString can convert from SQLDateTime if no locale was set (nil).
// Use nil locale for SQLDateTime Var date1 As DateTime = DateTime.FromString(mySQLDateTimeString, Nil) // If required make datetime local Var localDate As New DateTime(date1.secondsFrom1970, Locale.Current) // Change locale to wishes.