I have a date string in this format:
2016-06-20T13:01:46.457+02:00
and I need to change it to something like this:
20/06/2016
Previously I have always used this library -> SwiftDate to manipulate the dates, but it doesn't work now.
I tried also something like:
let myDate = self.dateNoteDict[indexPath.row]!
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd hh:mm:ss.SSSSxxx"
let date = dateFormatter.dateFromString(myDate)
print("date -> \(date)")
but it doesn't work. How can I do?
Thanks in advance.
I always use this code while converting
String
toDate
. (Swift 3)and just call like . .
The standard ISO8601 date format with fractional seconds and time zone is
Swift 3:
In macOS 10.13+, iOS 11+
ISO8601DateFormatter
is an alternative as input formatter