Age between two dates for age calculator
NSCalendar *sysCalendar = [NSCalendar currentCalendar];
unsigned int unitFlags = NSHourCalendarUnit | NSMinuteCalendarUnit | NSDayCalendarUnit | NSMonthCalendarUnit;
NSDateComponents *conversionInfo = [sysCalendar components:unitFlags fromDate:firstDate toDate:secondDate options:0];
NSLog(@"Conversion: %dmin %dhours %ddays %dmoths %dYear",[conversionInfo minute], [conversionInfo hour], [conversionInfo day], [conversionInfo month]%12,[conversionInfo month]/12);
NSString *result2 = [NSString stringWithFormat:@"%d year, %d month and %d day",[conversionInfo month]/12,[conversionInfo month]%12,[conversionInfo day]];
Comments
Post a Comment