iOS检查指定日期是否在当前日期之前, 直接上代码:
- (BOOL)checkProductDate: (NSString *)tempDate {NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];[dateFormatter setDateFormat:@"yyyy-MM-dd"];NSDate *date = [dateFormatter dateFromString:tempDate];// 判断是否大于当前时间if ([date earlierDate:[NSDate date]] != date) {return true;} else {return false;}}