1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
-(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; }
|
近期评论