Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine if today's date is in a range of two dates on iOS [duplicate]

Tags:

iphone

nsdate

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

like image 266
Sam Jarman Avatar asked Nov 26 '11 04:11

Sam Jarman


1 Answers

- (BOOL)isDate:(NSDate *)date inRangeFirstDate:(NSDate *)firstDate lastDate:(NSDate *)lastDate {
   return [date compare:firstDate] == NSOrderedDescending &&
          [date compare:lastDate]  == NSOrderedAscending;
}
like image 182
zaph Avatar answered Nov 11 '22 12:11

zaph