How do you return the system time zone as a string?

objective-c

Solution

It sounds like you want this:

`NSString *timeZoneName = [[NSTimeZone localTimeZone] name];`

That returns "America/New_York" for me, here in the EST time zone.

Or given any `NSTimeZone *tz` you can get its `[tz name]`, which is the conventional name you are looking for (e.g. "Asia/Tokyo" or "Europe/London".

Look at `+[NSTimeZone knownTimeZoneName]` for a list of possible names.

I hope that helps.

Problem

I have an app where I set time zones for various cities around the globe. I have no problem doing this and it works great. When the app first loads, it finds your current location (lat & long) and sets the time zone using the device default time zone. I need to return the default time zone in a string, so I can display it. I don't want "GMT" or "EDT", I would like it in the format of "America/New_York" or 'Europe/London". Any ideas?

Original source