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 using:
let dateFormatter = NSDateFormatter()
dateFormatter.dateStyle = .MediumStyle
dateFormatter.doesRelativeDateFormatting = true
let uploadDate = dateFormatter.stringFromDate(date)
Only "Today" and "Yesterday" are represented and the rest of the dates appear like the below: Nov 24, 2014 Nov 17, 2014 etc...
Is there another way to represent all the dates using relative dating instead of the actual dates?
You should have a look at Mattt Thompsons Blog post about NSDateComponentsFormatter
http://nshipster.com/nsdatecomponents/ and http://nshipster.com/nsformatter/
Example (by Mattt Thompson)