I have the following code:
NSDate *commentPostedDate = [[NSDate alloc] initWithTimeIntervalSince1970:[self.newsFeedStream_.timestamp_ intValue]];
NSLog(@"TIMESTAMP IS %@", self.newsFeedStream_.timestamp_);
int interval = (int) [[NSDate date] timeIntervalSinceDate:commentPostedDate] / 60;
[commentPostedDate release];
NSString *timePosted = [NSString stringWithFormat:@"%d hours ago", interval];
However this doesn’t seem to return the correct hours ago. What am I doing wrong here?
UNIX timestamps are usually in seconds, so why are you dividing by 60 if you want hours?
There are 3600 seconds in an hour, not 60.