把时间戳转化为时间

-(NSString*)SetTime:(NSString *)time{

NSDateFormatter*formatter = [[NSDateFormatter alloc]init];

[formatter setDateStyle:NSDateFormatterMediumStyle];

[formatter setTimeStyle:NSDateFormatterShortStyle];

[formatter setDateFormat:@"yyyy-MM-dd HH:mm"];

//  这个 time转double 除1000 是我们自己后台 时间戳传的问题

double timeval = [time doubleValue]/1000;

NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:timeval];

NSLog(@"1296035591  = %@",confromTimesp);

NSString *confromTimespStr = [formatter stringFromDate:confromTimesp];

NSLog(@"订单时间xxxx  = %@",confromTimespStr);

return confromTimespStr;

}

你可能感兴趣的:(把时间戳转化为时间)