ios 把毫秒值转换成日期 NSDate

ios 把毫秒值转换成日期 (比较好用)

1343359790000 这是毫秒值
------最佳解决方案--------------------
long long time=1343359790000LL;
NSDate *date = [[[NSDate alloc]initWithTimeIntervalSince1970:time/1000.0]autorelease];

------其他解决方案--------------------
接上,转成可见的年月日格式日期的话可以:
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
dateFormatter.dateFormat = @"yyyy-MM-dd";
return [dateFormatter stringFromDate:date];
------其他解决方案--------------------
还可以使用dateWithTimeIntervalSinceNow或者dateWithTimeIntervalSinceReferenceDate

转载于:https://www.cnblogs.com/someonelikeyou/p/3532802.html

猜你喜欢

转载自blog.csdn.net/weixin_34129145/article/details/94538693