+(NSString *)formatTime:(NSDate *)time
{
NSTimeInterval diff=-[time timeIntervalSinceNow];
if (diff<60) {
return @"刚刚";
}else if(diff<60*60){
int minute=diff/60;
return [NSString stringWithFormat:@"%d分钟以内",minute];
}else if(diff<24*60*60){
int hour=diff/(60*60);
return [NSString stringWithFormat:@"%d小时以内",hour];
}else{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat: @"MM-dd"];
NSString *timeStr=[dateFormatter stringFromDate:time];
return timeStr;
}
}
网友评论