I have this string date value
let stringDate = 2018-06-10T13:57:23.232+0000
the string date format will always be the same and I want to have output similar to one of these
6 year, 3 month, 1 day
or
3 month, 20 days
or
1 day
Basically I'm comparing the stringDate with current date and display how far they are apart from each other.
I'm able to get the date from string using this
let dateFormatter = DateFormatter()
var dateFromString: Date?
dateFormatter.timeZone = NSTimeZone.local
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
if let dateReturn = dateFormatter.date(from: stringDate) {
dateFromString = dateReturn
}
but I'm stuck on how to get the custom input like above. Thank you for helping me