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

posted on   ACM_Someone like you  阅读(2972)  评论(0编辑  收藏  举报

努力加载评论中...

导航

点击右上角即可分享
微信分享提示