Search code examples
iosnsdateformatternstimezone

NSTimeZone timeZoneWithName abbreviation shows different Abbreviations on different devices


I want to display "EDT" on label. I used below line and I found it to be working on iphone6, 6+ and iphone4 (iOS 7.1). But testing it on iPhone5s(iOS 8.2), iPhone5(iOS 7.1) I noticed it showing "GMT-4"

NSString *labelString = [NSString stringWithFormat:@"%@",[[NSTimeZone timeZoneWithName:@"America/New_York"] abbreviation]]

Is it device time zone related issue or can someone point out where am I making mistake please. Thanks in advance.


Solution

  • This was because of the timezone which was set on the devices. Different devices had different timezones set and that made this change in

    [[NSTimeZone timeZoneWithName:@"America/New_York"] abbreviation]]