Skip to content

Instantly share code, notes, and snippets.

@blakemerryman
Created April 27, 2018 21:26
Show Gist options
  • Save blakemerryman/245ac5185a31f99eaa012eb6077942f5 to your computer and use it in GitHub Desktop.
Save blakemerryman/245ac5185a31f99eaa012eb6077942f5 to your computer and use it in GitHub Desktop.
A fully ISO 8601 compliant date formatter
extension DateFormatter {
static let iso8601Full: DateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ"
formatter.calendar = Calendar(identifier: .iso8601)
formatter.timeZone = TimeZone(secondsFromGMT: 0)
formatter.locale = Locale(identifier: "en_US_POSIX")
return formatter
}()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment