-3
내 질문에 iOS의 두 가지 다른 날짜 사이의 일을 계산하는 것입니다. 을 사용하면 두 날짜 사이의 일 수를 계산할 수 있습니다. 나는 오늘 날 사이에 몇 일 동안 1990/02/05를 계산해야합니다.ios에서 두 날짜 사이의 일 계산 방법. 두 날짜 사이
내 질문에 iOS의 두 가지 다른 날짜 사이의 일을 계산하는 것입니다. 을 사용하면 두 날짜 사이의 일 수를 계산할 수 있습니다. 나는 오늘 날 사이에 몇 일 동안 1990/02/05를 계산해야합니다.ios에서 두 날짜 사이의 일 계산 방법. 두 날짜 사이
이 시도 :
NSString *start = @"2010-09-01";
NSString *end = @"2010-12-01";
NSDateFormatter *f = [[NSDateFormatter alloc] init];
[f setDateFormat:@"yyyy-MM-dd"];
NSDate *startDate = [f dateFromString:start];
NSDate *endDate = [f dateFromString:end];
NSCalendar *gregorianCalendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *components = [gregorianCalendar components:NSDayCalendarUnit
fromDate:startDate
toDate:endDate
options:0];
NSLog(@"%ld", [components day]);
저에게 귀중한 답변을 주신 데 대해 감사드립니다. –
[1 링크 (http://stackoverflow.com/questions/4575689/objective-c-calculating-the-number-of-days-between-two-dates) 및 [링크 2] (http://stackoverflow.com/questions/13236719/number-of-days-between-two-nsdate-objects) [링크 3] (http://stackoverflow.com/questions/4739483/number) 2 일간의 일 - 일) –
[가장 쉬운 방법] (https://www.google.co.in/search?client=safari&rls=en&q=cocoa+number+of+days+between+two + 날짜 & ie = UTF-8 & oe = UTF-8 & gfe_rd = cr & ei = vA57U8bBK4vC8gfzxYDICA) –