美文网首页
把时间戳转化为时间

把时间戳转化为时间

作者: 来敲代码 | 来源:发表于2017-02-20 12:00 被阅读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;

}

相关文章

网友评论

      本文标题:把时间戳转化为时间

      本文链接:https://www.haomeiwen.com/subject/tnnswttx.html