Say I have the following:
NSDate *today = [NSDate date];
How do I just the get integer value for the month? day? or year?
Say I have the following:
NSDate *today = [NSDate date];
How do I just the get integer value for the month? day? or year?
You want this NSDateCOmponenets
specifically:
- (NSDateComponents *)components:(NSUInteger)unitFlags fromDate:(NSDate *)date
Or you could just use the NSDate class:
NSDate *date = [NSDate date];
int month = [[date descriptionWithCalendarFormat:@"%m" timeZone:nil locale:nil] intValue];
int day = [[date descriptionWithCalendarFormat:@"%d" timeZone:nil locale:nil] intValue];
int year = [[date descriptionWithCalendarFormat:@"%Y" timeZone:nil locale:nil] intValue];
NSLog(@"Today: %i-%i-%i", year, month, day);
Hope it works, ief2