How to get full time zone name ios

PAn Kaj Khatri picture PAn Kaj Khatri · Jul 10, 2015 · Viewed 11.8k times · Source

How do we get full time zone name in iOS like Indian Standard Time instead of IST.

NSTimezone *timeZone=[NSTimeZone localTimeZone];

i am getting GMT but i want it like full form string

Answer

Alaeddine picture Alaeddine · Jul 10, 2015

You can get the name from the name property:

 NSTimeZone *timeZone = [NSTimeZone localTimeZone];
 NSLog(@"Name: %@", timeZone.name);

Result:

2015-07-10 13:31:46.292 APP[2904:50429] Name : Asia/Calcutta

You can to get the name with the desired style NSTimeZoneNameStyle using - localizedName:locale:

NSTimeZone* timeZone = [NSTimeZone timeZoneWithAbbreviation:@"IST"];
NSString* timeZoneName = [timeZone localizedName:NSTimeZoneNameStyleStandard locale:[NSLocale currentLocale]];
NSLog(@"Name : %@", timeZoneName);

Result:

2015-07-10 13:36:31.771 APP[2940:51197] Name : India Standard Time

If you call [NSTimeZone abbreviationDictionary] you'll get a dictionary containing all available abbreviations.

NSLog(@"%@",[NSTimeZone abbreviationDictionary]);

Result :

2015-07-10 11:44:05.954 APP[1472:26120] {
    ADT = "America/Halifax";
    AKDT = "America/Juneau";
    AKST = "America/Juneau";
    ART = "America/Argentina/Buenos_Aires";
    AST = "America/Halifax";
    BDT = "Asia/Dhaka";
    BRST = "America/Sao_Paulo";
    BRT = "America/Sao_Paulo";
    BST = "Europe/London";
    CAT = "Africa/Harare";
    CDT = "America/Chicago";
    CEST = "Europe/Paris";
    CET = "Europe/Paris";
    CLST = "America/Santiago";
    CLT = "America/Santiago";
    COT = "America/Bogota";
    CST = "America/Chicago";
    EAT = "Africa/Addis_Ababa";
    EDT = "America/New_York";
    EEST = "Europe/Istanbul";
    EET = "Europe/Istanbul";
    EST = "America/New_York";
    GMT = GMT;
    GST = "Asia/Dubai";
    HKT = "Asia/Hong_Kong";
    HST = "Pacific/Honolulu";
    ICT = "Asia/Bangkok";
    IRST = "Asia/Tehran";
    IST = "Asia/Calcutta";
    JST = "Asia/Tokyo";
    KST = "Asia/Seoul";
    MDT = "America/Denver";
    MSD = "Europe/Moscow";
    MSK = "Europe/Moscow";
    MST = "America/Denver";
    NZDT = "Pacific/Auckland";
    NZST = "Pacific/Auckland";
    PDT = "America/Los_Angeles";
    PET = "America/Lima";
    PHT = "Asia/Manila";
    PKT = "Asia/Karachi";
    PST = "America/Los_Angeles";
    SGT = "Asia/Singapore";
    UTC = UTC;
    WAT = "Africa/Lagos";
    WEST = "Europe/Lisbon";
    WET = "Europe/Lisbon";
    WIT = "Asia/Jakarta";
}