日期年月日的比较以及判断
Posted WW倩
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了日期年月日的比较以及判断相关的知识,希望对你有一定的参考价值。
//对比的时间
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;
}
以上是关于日期年月日的比较以及判断的主要内容,如果未能解决你的问题,请参考以下文章