Skip to content

Instantly share code, notes, and snippets.

@abargh
Created September 11, 2018 07:58
Show Gist options
  • Save abargh/92e4c5e48b49dc8a7e33212a4421d337 to your computer and use it in GitHub Desktop.
Save abargh/92e4c5e48b49dc8a7e33212a4421d337 to your computer and use it in GitHub Desktop.
Swift iso8601 Date formatter
import Foundation
extension DateFormatter {
static let iso8601: DateFormatter = {
let formatter = DateFormatter()
formatter.calendar = Calendar(identifier: .iso8601)
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.timeZone = TimeZone(secondsFromGMT: 0)
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss'Z'"
return formatter
}()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment