ios 把毫秒值轉換成日期 (比較好用)
1343359790000 這是毫秒值
------最佳解決方案--------------------
------其他解決方案--------------------
接上,轉成可見的年月日格式日期的話可以:
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
dateFormatter.dateFormat = @"yyyy-MM-dd";
return [dateFormatter stringFromDate:date];
------其他解決方案--------------------
還可以使用dateWithTimeIntervalSinceNow或者dateWithTimeIntervalSinceReferenceDate
------最佳解決方案--------------------
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