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

Popular posts from this blog

Launch iPhone simulator without Xcode.

How to Make REST api call in Objective-C.

id vs NSObject