How to compare date in objective c. i have three date in nsstring format. Here i have to check whether a date is occurred inbetween or equal to two other dates. How to impleme开发者_开发问答nt this any source code and tutorials, idea...?
here what i done so far...
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"yyyy/dd/MM"];
NSDate *date1 = [dateFormat dateFromString:[State getIncurredDate]];
NSDate *date2 = [dateFormat dateFromString:startDate];
NSDate *date3 = [dateFormat dateFromString:endDate];
if( [date isEqualToDate:otherDate] )
NSLog(@"%@ is equal to %@",date,otherDate);
Done.
You can convert your dates into TimeInterval (since some reference date) and just compare numbers.
精彩评论