美文网首页
时间戳转NSDate

时间戳转NSDate

作者: eb7a9dac29d0 | 来源:发表于2017-08-14 10:30 被阅读0次

- (NSDate *)timeWithTimeIntervalDate:(NSString *)Date

{

// 格式化时间

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

formatter.timeZone = [NSTimeZone timeZoneWithName:@"shanghai"];

[formatter setDateStyle:NSDateFormatterMediumStyle];

[formatter setTimeStyle:NSDateFormatterShortStyle];

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

// 毫秒值转化为秒

NSDate* date = [NSDate dateWithTimeIntervalSince1970:[Date doubleValue]/ 1000.0];

return date;

}

相关文章

网友评论

      本文标题:时间戳转NSDate

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