问题
Possible Duplicate:
How to compare two dates in Objective-C
I'd like to pop up a message in one of my apps when the date is in the range of two dates (e.g. the holiday period)
So like
if(dateInRangeof:date1, date2){True}else{false}
Looking for any code snippets or apis to look at. Cheers
回答1:
- (BOOL)isDate:(NSDate *)date inRangeFirstDate:(NSDate *)firstDate lastDate:(NSDate *)lastDate {
return [date compare:firstDate] == NSOrderedDescending &&
[date compare:lastDate] == NSOrderedAscending;
}
回答2:
How to compare two dates in Objective-C
This should be what you're looking for.
If you look in the documentation for NSDate you should find a lot of interesting things.
来源:https://stackoverflow.com/questions/8276187/determine-if-todays-date-is-in-a-range-of-two-dates-on-ios