7.30关于时间戳转成时间格式
2017-07-30 本文已影响0人
小码农杰哥
NSString *strT = [NSString stringWithFormat:@"%@",dic[@"birthDate"]];
NSTimeInterval time = [strT integerValue]/1000;
//把毫秒转换成NSDate格式
NSDate *nd = [NSDate dateWithTimeIntervalSince1970:time];
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"yyyy-MM-dd"];
NSString *string = [dateFormat stringFromDate:nd];
self.dateStr = [NSString stringWithFormat:@"%@",string];
//当前时间转换成字符串
NSDate* data= [NSDate dateWithTimeIntervalSinceNow:0];
NSTimeInterval interval=[data timeIntervalSince1970]*1000;
NSString *timeStr = [NSString stringWithFormat:@"%0.f", interval];//转为字符型