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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM