开发者

iphone,objective c - Date comparison

开发者 https://www.devze.com 2023-02-07 01:32 出处:网络
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 an

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

精彩评论

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

关注公众号