开发者

iphone,objective c - Date comparison

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜