我有两个日期,比如 currentdate 和 getDate,我想比较 getdate 是旧的还是新的或相等的。
我试过这个供你参考:
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.
但是它不能正常工作,请任何人为此建议我。
提前致谢