I have a number of dates that I am trying to represent using a relative date such as \"Today, Yesterday, 1 week ago, 1 month ago\" etc...
This is the Swift code I am usi
iOS 13+ now has RelativeDateFormatter
For examples: https://nshipster.com/formatter/#relativedatetimeformatter
let formatter = RelativeDateTimeFormatter()
formatter.localizedString(from: DateComponents(day: 1, hour: 1)) // "in 1 day"
formatter.localizedString(from: DateComponents(day: -1)) // "1 day ago"
or
formatter.localizedString(for: date, relativeTo: Date())