Suppose right now, the date and time is 2015-01-10 10:30:00
. I have a date in the past like 2015-01-10 08:30:00
and another like 2015-01-09 15:00:00
.
Instead of displaying the date difference in number of days and seconds, I want to display something like 2 hours ago
or Yesterday
. If the date is too far away, something like December 2014
could be used. It's similar to the time in posts on popular social networks.
Is there an easy way or already existing piece of code for to achieve this or I will have to make my own implementation?
Thanks.
Edit: I'm working with objective-c. NSTimeInterval secondsBetween = [date2 timeIntervalSinceDate:date1];
will return the time in seconds. I am more in search of an existing solution/library