3
내가 이해할 수없는 시간 구성 요소를 변경하지 마십시오 NSLog는 다음과 같습니다 :NSDateComponents 내가 이런 식으로 그것을 할 것, 제대로
2012-12-08 06:00:00 +0000
차이가 한 시간 있습니다, 내가 7을 설정했지만 6 누구든지 나를 도울 수 있습니까?
내가 이해할 수없는 시간 구성 요소를 변경하지 마십시오 NSLog는 다음과 같습니다 :NSDateComponents 내가 이런 식으로 그것을 할 것, 제대로
2012-12-08 06:00:00 +0000
차이가 한 시간 있습니다, 내가 7을 설정했지만 6 누구든지 나를 도울 수 있습니까?
그 시간대 -이 구성 요소 GMT를하고 시간이
사용
[components setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
의 아무 개념이없는 것처럼있는 NSDate은 GMT 시간으로 인쇄
작업 예
int main(int argc, char *argv[]) {
@autoreleasepool {
NSDate *today = [NSDate date];
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *components = [calendar components: (NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate:today];
[components setMinute:50];
[components setHour:7];
[components setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
NSDate *myNewDate = [calendar dateFromComponents:components];
NSLog(@"%@",myNewDate);
}
}
내가 사용해야하는 시간대는 무엇입니까? – Piero
내 대답을 편집했습니다 –
대단히 감사합니다! – Piero