Here's an example code snippet that converts a given Australian Eastern Daylight Time (AEDT) date to GMT using Swift:
main.swift610 chars16 lines
The code creates a date formatter with the AEDT timezone, and uses it to convert the input date string to a Date
object. Then, it retrieves the GMT timezone and calculates the offset between the AEDT and GMT timezones for the given AEDT date. Finally, it uses the date(byAdding:to:options:)
method of Calendar
to subtract the GMT offset from the AEDT date and get the corresponding GMT date. The resulting GMT date can be used for further processing or display.
gistlibby LogSnag