Created
May 15, 2015 16:16
-
-
Save dleonard00/d92661a17cf26c31c978 to your computer and use it in GitHub Desktop.
RFC 3339 date string in Swift
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
var now = NSDate() | |
var localTimeZone = NSTimeZone.systemTimeZone() | |
var rfc3339DateFormatter = NSDateFormatter(format: "yyyy'-'MM'-'dd'T'HH':'mm':'ssZ") | |
rfc3339DateFormatter.locale = NSLocale( localeIdentifier: "en_US_POSIX") | |
rfc3339DateFormatter.timeZone = localTimeZone | |
var dateString = rfc3339DateFormatter.stringFromDate(now) | |
NSLog("RFC 3339 datetime: \(dateString)") | |
//reference: https://gist.github.com/popthestack/5877965 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See also: