To convert a GMT date to Alaska Timezone in Swift, you can follow the steps below:
DateFormatter class:main.swift36 chars2 linesmain.swift53 chars2 linesmain.swift49 chars2 linesDate object:main.swift141 chars5 linesmain.swift67 chars2 linesgmtDate to Alaska Timezone, and get the formatted date string:main.swift59 chars2 linesThe complete code snippet would look like this:
main.swift489 chars15 linesThis will print the output as:
main.swift63 chars3 linesNote: 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