把时间戳转化为时间

2017-02-20  本文已影响11人  来敲代码

-(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;

}

上一篇下一篇

猜你喜欢

热点阅读