To convert a GMT date to Alaska Timezone in Swift, you can follow the steps below:
DateFormatter
class:main.swift36 chars2 lines
main.swift53 chars2 lines
main.swift49 chars2 lines
Date
object:main.swift141 chars5 lines
main.swift67 chars2 lines
gmtDate
to Alaska Timezone, and get the formatted date string:main.swift59 chars2 lines
The complete code snippet would look like this:
main.swift489 chars15 lines
This will print the output as:
main.swift63 chars3 lines
Note: Make sure to replace the input gmtDate
string and the Alaska Timezone identifier ("America/Anchorage"
) with your own values as per your requirement.
gistlibby LogSnag