Last active
October 6, 2016 01:54
-
-
Save rydermackay/0396ea918ce420af842aa1474efbbc93 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Cocoa | |
private let _rfc3339Formatter: DateFormatter = { | |
let formatter = DateFormatter() | |
formatter.dateFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'" | |
formatter.timeZone = TimeZone(secondsFromGMT: 0) | |
formatter.locale = Locale(identifier: "en_US_POSIX") | |
return formatter | |
}() | |
extension DateFormatter { | |
static var rfc3339Formatter: DateFormatter { | |
return _rfc3339Formatter | |
} | |
} | |
let dateString = "2002-10-02T15:00:00Z" | |
DateFormatter.rfc3339Formatter.date(from: dateString) // "Oct 2, 2002, 11:00 AM" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment