ios 把毫秒值轉換成日期 NSDate
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
posted on 2014-01-24 18:35 ACM_Someone like you 閱讀(2983) 評論(0) 收藏 舉報
浙公網安備 33010602011771號