Skip to content

Instantly share code, notes, and snippets.

@xhinking
Created April 23, 2013 07:24
Show Gist options
  • Save xhinking/5441488 to your computer and use it in GitHub Desktop.
Save xhinking/5441488 to your computer and use it in GitHub Desktop.
is same day method in obejctive c
- (BOOL)isSameDay:(NSDate*)date1 otherDay:(NSDate*)date2 {
NSCalendar* calendar = [NSCalendar currentCalendar];
unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit;
NSDateComponents* comp1 = [calendar components:unitFlags fromDate:date1];
NSDateComponents* comp2 = [calendar components:unitFlags fromDate:date2];
return [comp1 day] == [comp2 day] &&
[comp1 month] == [comp2 month] &&
[comp1 year] == [comp2 year];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment