iOS如何得到精確到微秒或毫秒的NSDate值?
已經解決了。NSTimeInterval本身是個秒級別的double類型數值,小數點後面即毫秒數,*1000.0f即可得到毫秒級別的時間差//為了兼容java版本,事件是從1970/1/1開始-(NSDate *)getDateTimeFromMilliSeconds:(long long) miliSeconds{ NSTimeInterval tempMilli = miliSeconds; NSTimeInterval seconds = tempMilli/1000.0; NSLog(@"seconds=%f",seconds); return [NSDate dateWithTimeIntervalSince1970:seconds];}//將NSDate類型的時間轉換為NSInteger類型,從1970/1/1開始-(long long)getDateTimeTOMilliSeconds:(NSDate *)datetime{ NSTimeInterval interval = [datetime timeIntervalSince1970]; NSLog(@"interval=%f",interval); long long totalMilliseconds = interval*1000 ; NSLog(@"totalMilliseconds=%llu",totalMilliseconds); return totalMilliseconds; }