Get timezone name from NSDate

Any way to get the abbreviation from timezone (e.g. UTC, EET) from NSDate? I get an NSDate from a string, for example, 2012-08-26 02:54:50 +0200 and I need to show the time zone of this date.

Currently it is:

NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease];
[formatter setDateFormat: @"yyyy-MM-dd HH:mm:ssZZZ"];
NSDate *isoDate = [formatter dateFromString: isoTime.value];
NSInteger offset = [[NSTimeZone defaultTimeZone] secondsFromGMTForDate: isoDate];
NSTimeZone *timeZone = [NSTimeZone timeZoneForSecondsFromGMT: offset];

But I get GMT + 03: 00 for the abbreviation timeZone, but it should be EET. Any way to get it?

+5
source share
1 answer

An is NSDateindependent of the time zone; it essentially does not have a time zone. Therefore, you cannot get the time zone from it.

secondsFromGMTForDate: ( ) GMT . NSTimeZone, (, ), .

+7

All Articles