The code below is displays the time and time zone. It works but returns different results on my Mac (and simulator) to on my real iPhone. The first part is fine because it displays the 12 or 24 hour clock as set on the device (which is what I want). Unfortunately, the time zone is coming out as a GMT offset on the phone rather than as the local time zone name as on the Mac.
Question: How do I make the time zone display as EST
on the iPhone?
let zone = TimeZone(identifier: "America/New_York")
let f1 = DateFormatter()
f1.timeZone = zone
f1.timeStyle = .short
let f2 = DateFormatter()
f2.timeZone = zone
f2.dateFormat = "z"
print("\(f1.string(from: Date())) \(f2.string(from: Date()))")
Prints 2:14 pm EST
on the Mac or iPhone simulator.
Prints 14:14 GMT-5
on the iPhone.
Both the iPhone and the MacBook are set to "English (UK)" language with the region set to "United Kingdom".