나는 currentdate와 getDate와 같은 두 개의 날짜를 가지고 있는데, 나는 getdate가 old 또는 new 또는 equal과 비교하기를 원한다. objectiveC에서 두 날짜 비교?
내가 참조를 위해이 시도 :NSDate *today = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MM/dd/yyyy"];
NSString *currentDate = [dateFormatter stringFromDate:today];
// Current_date (7/26/2013)
NSString *getdate=[outDateformatter1 stringFromDate:bDt1];
// Get_date (7/26/2010)
NSComparisonResult result;
result = [currentDate compare:getdate]; // comparing two dates
if(result==NSOrderedAscending)
NSLog(@"today is less");
I need this, Original result getdate is old date.
그러나이 제대로 작동하지 않는, 어떤 일이 저를 제안 해주십시오. 사전
]을 참조 링크 http://stackoverflow.com/questions/7901061/comparing-two-dates-with-nsdate?rq=1 – Pradeep
당신이 날짜를 비교할 때,있는 NSDate 당신이 그들로부터 생성 문자열이 아닌 객체 비교 , isEqualToDate :를 사용하십시오. – rdelmar
날짜 객체를 문자열이 아닌 비교합니다. –