Skip to content

Instantly share code, notes, and snippets.

@robertmryan
Created October 14, 2019 04:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertmryan/10f0d15735ef72bf51c1765cd9918f85 to your computer and use it in GitHub Desktop.
Save robertmryan/10f0d15735ef72bf51c1765cd9918f85 to your computer and use it in GitHub Desktop.
// Personally, I would have done this on `DateFormatter` extension, but
// did it on Formatter so it would work with provided code snippet.
extension Formatter {
static var iso8601: DateFormatter = {
let formatter = DateFormatter()
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.timeZone = TimeZone(secondsFromGMT: 0)
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSSSS"
return formatter
}()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment