判断某个时间是否大于当前时间

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];

[dateFormatter setDateFormat:@"yyyy-MM-dd"];

//string转date

NSDate *date = [dateFormatter dateFromString:StartDate];

NSDate *laterdate = [dateFormatter dateFromString:EndDate];

//判断某个时间是否大于当前时间

if([date earlierDate:[NSDate date]] == date && [laterdate laterDate:[NSDate date]] == laterdate)

{

NSLog(@"在范围内");

}

你可能感兴趣的:(判断某个时间是否大于当前时间)