Created
March 5, 2016 06:10
-
-
Save wjlafrance/87cde2d0800402fa3d17 to your computer and use it in GitHub Desktop.
I don't know how to dateformatter
This file contains hidden or 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
Expect: 2016-02-08 15:43:32 +0000 | |
Got: 2016-02-08 18:43:32 +0000 | |
2016-02-08 12:43:32 +0000 |
This file contains hidden or 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 Foundation | |
let formatter = NSDateFormatter() | |
formatter.dateFormat = "M/d/yyyy H:mm:ss a" | |
let date1 = formatter.dateFromString("2/8/2016 3:43:32 PM")! | |
formatter.timeZone = NSTimeZone(name: "GMT")! | |
let date2 = formatter.dateFromString("2/8/2016 3:43:32 PM")! | |
print("Expect: 2016-02-08 15:43:32 +0000") | |
print("Got: \(date1)") | |
print(" \(date2)") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment