So I'm trying to get the amount of days a blog post was posted ago. The end result would be something like "posted X days ago."
After spending some time on the problem, I figured it out by getting the NSTimeInterval, dividing to get days and then rounding. Although I got the output I wanted, I feel I am doing it wrong or there is a much more straight forward way of doing it.
tempDate
is a NSDate
object of when the blog was posted.
NSTimeInterval timeSince = [tempDate timeIntervalSinceNow];
timeSince = timeSince/60/60/24*-1; // seconds to days
int daysSince = lroundf(timeSince);