首页 > 代码库 > 日期年月日的比较以及判断
日期年月日的比较以及判断
//对比的时间
NSCalendar *gregorian = [[NSCalendar alloc]initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
[gregorian setFirstWeekday:2];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyyMMddHHmmss"];
NSDate *fromDate;
NSDate *toDate;
[gregorian rangeOfUnit:NSCalendarUnitMinute startDate:&fromDate interval:NULL forDate:[dateFormatter dateFromString:tisuTime]];
[gregorian rangeOfUnit:NSCalendarUnitMinute startDate:&toDate interval:NULL forDate:[NSDate date]];
NSDateComponents *dayComponents = [gregorian components:NSCalendarUnitMinute fromDate:fromDate toDate:toDate options:0];
if (dayComponents.minute >= 0 && dayComponents.minute<60) {
[self.tisuBtn setTitle: @"已加速" forState:UIControlStateNormal];
_tisuBtn.backgroundColor = BUTTON_UNSELECT;
}else{
//如果大于一小时之后就可以再次点击
[self.tisuBtn setTitle: @"加速审核" forState:UIControlStateNormal];
_tisuBtn.backgroundColor = MAINCOLOR;
}
日期年月日的比较以及判断