+(NSString *)countdownStartTime:(NSString *)startTime{ NSString *TIME = [startTime substringToIndex:10]; NSTimeInterval time = [TIME floatValue]; NSDate *oldDate = [NSDate dateWithTimeIntervalSince1970:time]; // NSDate *oldDate = [NSDate date]; NSDate *currentDate = [NSDate date]; NSLog(@"lastDate == %@",currentDate); NSCalendar *cal = [NSCalendar currentCalendar]; unsigned int unitFlags = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour | NSCalendarUnitMinute | NSCalendarUnitSecond; NSDateComponents *dateComponents = [cal components:unitFlags fromDate:oldDate toDate:currentDate options:0]; float sec = [dateComponents hour]*3600 + [dateComponents minute]*60+ [dateComponents second]; float surplusMin = (30*60 - sec)/60; if (surplusMin == 00) { return @"订单关闭"; }else{ return [NSString stringWithFormat:@"剩余:%d分%d秒", [dateComponents minute],[dateComponents second]]; } }