网络请求下来的字符串转化成时间

#pragma mark - 网络请求下来的字符串转化成时间
/** ba网络请求下来的字符串转化成时间 */
- (NSString *)timeWithString:(NSString *)time{
    NSString *messageTime = time;
    NSInteger num = [messageTime integerValue];
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    [formatter setDateStyle:NSDateFormatterMediumStyle];
    [formatter setTimeStyle:NSDateFormatterShortStyle];
    [formatter setDateFormat:@"yyyy/MM/dd"];
    NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:num];
    NSString *confromTimespStr = [formatter stringFromDate:confromTimesp];
    
    return confromTimespStr;
}

你可能感兴趣的:(网络请求下来的字符串转化成时间)