1
此代碼。NSDate關於日期和時間顯示
NSDate *today = [NSDate date];
NSArray *langs = [NSLocale preferredLanguages];
NSString *langID = [langs objectAtIndex:0];
NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:langID];
*format = [[NSDateFormatter alloc] init];
[format setLocale:locale];
[format setDateFormat:@"yyyy/MM/dd HH:mm:ss"];
strTime = [[NSString alloc] initWithFormat:@"%@",[format stringFromDate:today]];
today is +0000.
langID is en.
but,strTime is Japan time.
爲什麼? 我想根據語言設置顯示日期和時間。
Language!=時區。目前還不清楚你想在這裏看到什麼,你能擴展這個問題嗎? – jrturton
[NSLocale currentLocale]和[NSCalendar currentCalendar] ..看看文檔隊友 –
用戶可以設置與他們的時區不同的區域設置。你在做什麼? –