Pragnesh Patel Pragnesh Patel - 1 month ago 5
iOS Question

timezoneWithAbbreviation:@"CST" return America/Chicago (CDT) value

I want to find the timezone for "Saskatoon, Saskatchewan, Canada" (Whose timezone is CST), so I am using the abbreviation CST on following method:

var timezone = NSTimeZone.init(abbreviation: "CST")
print(timezone)


OUTPUT:


America/Chicago (CDT) offset -18000 (Daylight)


Why am I getting a value of CDT while I am passing CST?

Can anyone help me how can I get correct value using
timezoneWithAbbreviation:
method for CST abbreviation of "Saskatoon, Saskatchewan, Canada" ?

Answer

You can try initialising your NSTimeZone with location tzname (for TimeZone use this) instead of abbreviation.

For Saskatchewan it would be "Canada/East-Saskatchewan", "Canada/Saskatchewan" or "America/Regina".

Comments