Last active
April 25, 2017 02:46
-
-
Save perlmunger/ddafb785a11a6bba9f43cd3324d98c72 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
// ISO 8601 Extension for Swift to send dates to Ruby on Rails | |
extension Date { | |
init(dateString:String) { | |
self = Date.iso8601Formatter.date(from: dateString)! | |
} | |
static let iso8601Formatter: ISO8601DateFormatter = { | |
let formatter = ISO8601DateFormatter() | |
formatter.formatOptions = [.withFullDate, | |
.withTime, | |
.withDashSeparatorInDate, | |
.withColonSeparatorInTime] | |
return formatter | |
}() | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://stackoverflow.com/questions/28016578/swift-how-to-create-a-date-time-stamp-and-format-as-iso-8601-rfc-3339-utc-tim#42101630