iOS计算两个时间的时间差
2017-04-12 09:35
363 查看
/** * 计算剩余时间 * * @param endTime 结束日期 * * @return 剩余时间 */ -(NSString *)getCountDownStringWithEndTime:(NSString *)endTime { NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm"]; NSDate *now = [NSDate date]; NSTimeZone *zone = [NSTimeZone systemTimeZone];//设置时区 NSInteger interval = [zone secondsFromGMTForDate: now]; NSDate *localDate = [now dateByAddingTimeInterval: interval]; endTime = [NSString stringWithFormat:@"%@ 23:59", endTime]; NSDate *endDate = [dateFormatter dateFromString:endTime]; NSInteger endInterval = [zone secondsFromGMTForDate: endDate]; NSDate *end = [endDate dateByAddingTimeInterval: endInterval]; NSUInteger voteCountTime = ([end timeIntervalSinceDate:localDate]) / 3600 / 24; NSString *timeStr = [NSString stringWithFormat:@"%d", voteCountTime]; return timeStr; }
相关文章推荐
- iOS 计算两个时间的时间差
- ios 计算两个时间之间的时间差
- iOS计算两个时间的时间差
- iOS 计算当前时间与过去某一时间的时间差
- C语言输入两个时间,计算两个时间的时间差!
- js 计算两个时间的时间差
- Oracle中计算两个时间的时间差:
- java计算两个时间的时间差
- iOS规范化时间格式,object-C计算指定时间与当前的时间差
- IOS_计算当前时间与某时间的时间差
- iOS 获取当前时间以及计算年龄(时间差)
- java工具类-计算相对时间的工具类即两个时间的时间差
- 问题:C#时间差;结果:C# 使用TimeSpan计算两个时间差
- 在windows下计算两个时间的时间差(精确到毫秒)
- iOS 获取当前时间以及计算年龄(时间差)
- golang 计算两个时间的时间差
- 计算两个时间的时间差
- C#计算两个时间的时间差,精确到年月日时分秒
- 计算两个时间的时间差 就是 计算执行一段程序使用的时间
- js前台计算两个日期的间隔时间(时间差)