Skip to content

Instantly share code, notes, and snippets.

@lfaoro
Created August 31, 2014 13:21
Show Gist options
  • Save lfaoro/c8d63a58ae26df2f24ff to your computer and use it in GitHub Desktop.
Save lfaoro/c8d63a58ae26df2f24ff to your computer and use it in GitHub Desktop.
test
NSDate *now = [NSDate date];
NSDateFormatter *format = [[NSDateFormatter alloc]init];
[format setDateFormat:@"yyyy-MM-dd"];
NSString *nowDate = [format stringFromDate:now];
NSLog(@"test: %@",nowDate);
NSDateComponents *comps = [[NSDateComponents alloc] init];
[comps setDay:27];
[comps setMonth:9];
[comps setYear:1988];
NSCalendar *local = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDate *birthDay = [local dateFromComponents:comps];
double difference = [now timeIntervalSinceDate:birthDay];
double years = (((difference /60) /60) /24) /365;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment