7.30关于时间戳转成时间格式

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];//转为字符型

你可能感兴趣的:(7.30关于时间戳转成时间格式)