With the NSDate class. Use message timeIntervalSinceDate
. It will return you a NSTimeInterval value (actually it's a double) that represents the seconds elapsed since the date you want. After that, it's easy to convert seconds-to-days.
If you truncate seconds/86400
will give you days.
Let's say you want days since January 1st 2010.
// current date/time
NSDate *now = [[NSData alloc] init];
// seconds elapsed since January 1st 2010 00:00:00 (GMT -4) until now
NSInteval interval = [now timeIntervalSinceDate: [NSDate dateWithString:@"2010-01-01 00:00:00 -0400"]];
// days since January 1st 2010 00:00:00 (GMT -4) until now
int days = (int)interval/86400;