Guest User

Untitled

a guest
Feb 22nd, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. NSString *start = @"2010-09-01";
  2. NSString *end = @"2010-12-01";
  3.  
  4. NSDateFormatter *f = [[NSDateFormatter alloc] init];
  5. [f setDateFormat:@"yyyy-MM-dd"];
  6. NSDate *startDate = [f dateFromString:start];
  7. NSDate *endDate = [f dateFromString:end];
  8.  
  9. NSCalendar *gregorianCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
  10. NSDateComponents *components = [gregorianCalendar components:NSCalendarUnitDay
  11. fromDate:startDate
  12. toDate:endDate
  13. options:0];
  14. NSLog(@"%ld", [components day]);
Add Comment
Please, Sign In to add comment