For date comparison compare method use from NSDate.h,
this method return NSComparisonResult.
Custom method for date comparison:
-(BOOL)isBetweenDate:(NSDate *)yourDate startingDate:(NSDate *)startDate endingDate:(NSDate *)endDate
{
if ([yourDate compare:startDate] == NSOrderedAscending)
return NO;
if ([yourDate compare:endDate] == NSOrderedDescending)
return NO;
return YES;
}
Using this code for compare date:
if ([self isBetweenDate:yourDate startingDate:startDate endingDate:endDate])
{
NSLog(@"Your date is between start and end date");
}
else{
NSLog(@"Your date is not between start and end date");
}
No comments:
Post a Comment