首页 > 代码库 > IOS获取两个时间的毫秒差

IOS获取两个时间的毫秒差

IOS获取两个时间的毫秒差

by 伍雪颖

NSString *savedTime = [[NSUserDefaults standardUserDefaults] stringForKey:@"time"];
NSString *time = [NSString stringWithFormat:@"%f", (double)[[NSDate date] timeIntervalSince1970]];
NSLog(@"\n%@\n%@",time,savedTime);
NSLog(@"%.f",([time doubleValue] - [savedTime doubleValue]) * 1000);
[[NSUserDefaults standardUserDefaults] setObject:time forKey:@"time"];
[[NSUserDefaults standardUserDefaults] synchronize];