Here's an example code on how to convert Hawaii time to GMT in Swift:
main.swift452 chars10 lines
In the example above, we first create a DateFormatter instance and set the dateFormat property to match the format of the input date string. We also set the timeZone property of the formatter to "Pacific/Honolulu", which is the time zone for Hawaii.
Next, we use the formatter object to convert the input date string ("2021-10-03 15:30:00") to a Date object. Since the input date string is in the Hawaii time zone, the resulting Date object will also be in the Hawaii time zone.
We then change the time zone property of the formatter object to "GMT", which is the time zone we want to convert to. We use the formatter object again to convert the Hawaii time Date object to a string in the GMT time zone.
Finally, we print the output string, which should be "2021-10-04 01:30:00", representing the equivalent time in GMT.
gistlibby LogSnag