如何在 iphone sdk 代码中比较开始日期和结束日期?
示例:->
if ([nowdate compare:raceStartDate] == NSOrderedDescending && [nowdate compare:raceEndDate] == NSOrderedAscending)
{
}
如何在 iphone sdk 代码中比较开始日期和结束日期?
示例:->
if ([nowdate compare:raceStartDate] == NSOrderedDescending && [nowdate compare:raceEndDate] == NSOrderedAscending)
{
}
NSDate *date1;
NSDate *date2;
if ([date1 compare:date2] == NSOrderedDescending) {
NSLog(@"date1 is later than date2");
} else if ([date1 compare:date2] == NSOrderedAscending) {
NSLog(@"date1 is earlier than date2");
} else {
NSLog(@"dates are the same");
}
尝试这个
- (BOOL)date:(NSDate*)nowdate isBetweenDate:(NSDate*)raceStartDate andDate:(NSDate*)raceEndDate
{
if ([nowdate compare:raceStartDate] == NSOrderedAscending)
return NO;
if ([nowdate compare:raceEndDate] == NSOrderedDescending)
return NO;
return YES;
}