Created
September 3, 2018 17:17
-
-
Save micheltlutz/5421a774be2b82fa8a005a9b4f0bc932 to your computer and use it in GitHub Desktop.
Create Date from TimeStemp String
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
func formatterDate(stringDate: String) -> Date? { | |
let formatter = DateFormatter() | |
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSSxxxxx" | |
formatter.timeZone = Calendar.current.timeZone | |
formatter.locale = Calendar.current.locale | |
guard let newDate = formatter.date(from: stringDate) else { return nil } | |
return newDate | |
} | |
let stringDate = formatterDate(stringDate: "2018-08-30T15:26:27.357902-03:00") | |
print(stringDate) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment