Posted By

rabc on 10/18/10


Tagged

iphone datediff


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

bobbym245
synced


Days between two dates (datediff)


 / Published in: Objective C
 

  1. NSCalendar *gregorianCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
  2. NSUInteger unitFlags = NSHourCalendarUnit | NSMinuteCalendarUnit | NSDayCalendarUnit;
  3. NSDateComponents *components = [gregorianCalendar components:unitFlags
  4. fromDate:todaysDate
  5. toDate:lastDate
  6. options:0];
  7. [gregorianCalendar release];
  8.  
  9. NSString *days = [components day];

Report this snippet  

You need to login to post a comment.