I know exactly what you mean. Try this, I have been using this & it works perfectly for me -
Usage - [Utils humanDates:timeSinceEpoch];
+ (NSString *)humanDates:(NSString *)origDateInEpochTime
{
if([origDateInEpochTime length]<= 0)
return @"never";
NSDate *convertedDate = [NSDate dateWithTimeIntervalSince1970:[origDateInEpochTime doubleValue]/1000];
NSDate *todayDate = [NSDate date];
double ti = [convertedDate timeIntervalSinceDate:todayDate];
ti = ti * -1;
if(ti < 1)
{
return @"never";
}
else if(ti < 60)
{
return @"less than a minute ago";
}
else if(ti < 3600)
{
int diff = round(ti/60);
if(diff == 1)
return [NSString stringWithFormat:@"%d minute ago", diff];
else
return [NSString stringWithFormat:@"%d minutes ago", diff];
}
else if(ti < 86400)
{
int diff = round(ti/60/60);
if(diff == 1)
return [NSString stringWithFormat:@"%d hour ago", diff];
else
return [NSString stringWithFormat:@"%d hours ago", diff];
}
else if(ti < 2629743)
{
int diff = round(ti/60/60/24);
if(diff == 1)
return [NSString stringWithFormat:@"%d day ago", diff];
else
return [NSString stringWithFormat:@"%d days ago", diff];
}
else if(ti < 31104000)
{
int diff = round(ti/60/60/24/30);
if(diff == 1)
return [NSString stringWithFormat:@"%d month ago", diff];
else
return [NSString stringWithFormat:@"%d months ago", diff];
}
else if(ti < 311040000)
{
int diff = round(ti/60/60/24/30/12);
if(diff == 1)
return [NSString stringWithFormat:@"%d year ago", diff];
else
return [NSString stringWithFormat:@"%d years ago", diff];
}
else
{
int diff = round(ti/60/60/24/30/12/10);
if(diff == 1)
return [NSString stringWithFormat:@"%d decade ago", diff];
else
return [NSString stringWithFormat:@"%d decades ago", diff];
}
}