标签:
by 伍雪颖
+ (NSString *)formatTime:(NSString *)time { NSDateFormatter*dateFormatter =[[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSS"]; NSDate *date = [dateFormatter dateFromString:time]; [dateFormatter setDateFormat:@"YYYY/MM/dd"]; NSString *dateSent = [dateFormatter stringFromDate:date]; NSString *dateNow = [dateFormatter stringFromDate:[NSDate date]]; if ([dateSent isEqualToString:dateNow]) { [dateFormatter setDateFormat:@"HH:mm a"]; return [NSString stringWithFormat:@"Today %@",[dateFormatter stringFromDate:date]]; }else { [dateFormatter setDateFormat:@"MM/dd HH:mm a"]; return [dateFormatter stringFromDate:date]; } }
标签:
原文地址:http://www.cnblogs.com/bhlsheji/p/5095771.html