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] ..看看文档队友 –
用户可以设置与他们的时区不同的区域设置。你在做什么? –