시도 :
NSDateFormatter *form = [[NSDateFormatter alloc]init];
[form setDateFormat:@"dd.MM.yyyy"];
NSDate *dateA = [form dateFromString:@"17.05.2013"];
NSDate *dateB = [form dateFromString:@"25.05.2013"];
NSCalendar *calendar = [[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar] autorelease];
NSDateComponents *components = [calendar components:NSYearCalendarUnit|NSMonthCalendarUnit|NSDayCalendarUnit
fromDate:dateA
toDate:dateB
options:0];
strDiffyear = [NSString stringWithFormat:@"%i", components.year];
strDiffmonth = [NSString stringWithFormat:@"%i",components.month];
strDiffDays = [NSString stringWithFormat:@"%i",components.day];
lblDifference.text = [NSString stringWithFormat:@"%@ years %@ months %@ days",strDiffyear,strDiffmonth,strDiffDays];
당신은 날짜 차이 부문에 대한 많은 구성 요소를 가질 수 있습니다.
대답 어떤 쿼리, 무료 물어 경우 (:
이 시작 표시 할 가장 큰 장치, 예를 들면 년도에서 계산
가, 다음, 다음 장치를 계속 예를 들어 월 나머지 –
힌트를 계산한다. 변환 둘 다 1970 년부터 총 초 수로 나눕니다. –