格式1 通过(2014-12-11 22:22:22) 获得 今天22:22 ,昨天22:22 , 2天前 , 1个月前 , 3年前
NSString *dateStr = @"2015-01-15 22:22:22";
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"yyyy-MM-dd"];
NSRange r = [dateStr rangeOfString:@"-" options:NSBackwardsSearch]; // 找出最后一个-所在的位置
NSDate *date = [dateFormat dateFromString:[dateStr substringToIndex:r.location + 3]];
NSTimeInterval time = [[NSDate date] timeIntervalSinceDate:date]; // 获取date距离系统时间的总共秒数
int year = ((int)time / (3600 * 24 * 30 * 12));
int month = ((int)time / (3600 * 24 * 30));
int day = ((int)time / (3600 * 24));