2011-08-17 18 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]]; 
関連する問題