How do I get a String, "Pacific/Auckland" for example, from a user's TimeZone?
I can get the "NZST" abbreviation with
TimeZone.current.abbreviation()
But it's the full name I need, if I can get it.
One of these should work for you.
timeZone = TimeZone(abbreviation: "EST")
print(timeZone) // "some(America/New_York (current))\n"
print(timeZone.abbreviation()) // "Optional("EDT")\n"
print(timeZone.description) // "America/New_York (current)\n"
print(timeZone.identifier) // "America/New_York\n"
I believe you are looking for the last one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With