To convert Australian Central Daylight Time (ACDT) to Greenwich Mean Time (GMT) in Swift, you can use the TimeZone and Calendar classes provided by the Foundation framework.
First, you need to create instances of the time zones for ACDT and GMT:
main.swift110 chars3 linesNext, you can create a DateFormatter instance to parse a string representing a date in ACDT:
main.swift123 chars4 linesThen, you can use the Calendar class to calculate the equivalent Date object in GMT:
main.swift210 chars4 linesFinally, you can create another DateFormatter instance to format the gmtDate object as a string:
main.swift244 chars6 linesIn this example, we assume that the input date in ACDT is "2021-06-01 10:30:00". The output date in GMT should be "2021-06-01 01:00:00", because ACDT is nine and a half hours ahead of GMT during daylight saving time.
gistlibby LogSnag