2011-08-17 6 views
0

나는 objective-c (iOS) 개발을하고 있습니다. GMT +0의 기본 시간대를 GMT +8으로 변경하려면 어떻게해야합니까? GMT +8은 싱가포르입니다.시간대 변경

- (IBAction)dateChanged { 
    NSDate *choice = [datePick date]; 
    NSString *words = [NSString alloc initWithFormat:@"%@", choice]; 
    NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; 
    [dateFormat setDateFormat:@"yyyy-MM-dd HH:mm:ss"]; 

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"You have selected:" message:words delegate:nil cancelButoonTitle:@"OK" otherBUttonTitles:nil, nil]; 
    [alert show]; 
    [alert release]; 

    [words release]; 
} 

감사 :

여기 내 코드입니다.

답변

1

당신은 사용할 수

NSCalendar *calendar = [NSCalendar currentCalendar]; 
    [calendar setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]]; 

OR, 귀하의 경우에있을 것입니다

+ (id)timeZoneForSecondsFromGMT:(NSInteger)seconds 

,

[calendar setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:8*60*60]];