Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create Date from TimeStemp String
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
You can’t perform that action at this time.