2013-04-26 72 views
1

您好,我必须拿出timzone在NSTimeZoneNameStyleShortStandard格式如IST,MST等,但我不能够得到这个下面是我code.o/P就要像GMT+05:30而不是ISTNSTimeZoneNameStyleShortStandard不工作的iOS

NSTimeZone *systimeZone = [NSTimeZone systemTimeZone]; 
    NSString *timeZoneString = [systimeZone localizedName:NSTimeZoneNameStyleShortStandard locale:[NSLocale currentLocale]]; 
    if([systimeZone isDaylightSavingTimeForDate:[NSDate date]]){ 
     timeZoneString = [systimeZone localizedName:NSTimeZoneNameStyleShortDaylightSaving locale:[NSLocale currentLocale]]; 
    } 
NSLog(@"%@",timeZoneString); 

O/P 2013年4月27日04:41:01.679 DJProject [1460:C07] GMT + 05:30

+0

句子。标点。大/小写。拼写。 ......人们不会阅读糟糕的文字。 – Tricertops 2013-04-26 12:00:22

+0

你解决了吗? – Manny 2014-06-24 07:06:30

回答

0

您正在设置[NSLocale currentLocale]因此它示出了当前所用设备的区域设置。

+0

@Paras我应该怎么做,因为我需要我目前的设备时区。 – parvind 2013-04-26 12:00:57

+1

@parvind [NSTimeZone localTimeZone]这将返回您的本地设备时区。 – 2013-04-26 12:04:38

+0

雅和是以上代码返回当前设备时区... – 2013-04-26 12:05:41