I'm writing an app that needs to display and calculate all dates, times, timeintervals etc. from a specific, given timezone in Europe. Meaning, if I'm, say, in Paris, the app works flawlessly now, but if I go to New York, the app should display and work exactly as if I were still in Paris.
Naively, I tried (in the application: didFinishLaunchingWithOptions:
function)
[[NSCalendar currentCalendar] setTimeZone:[NSTimeZone timeZoneWithName:@"Europe/Paris"]];
but of course that doesn't work, all my NSDateFormatter objects still use the current timezone if not explicitly told otherwise.
So, what I'd like to know is:
Is there any way to globally enforce a timezone in an app? I'd rather not go through all my code and fix every single date formatter and date picker and so on if there's another way.
Will [NSTimeZone timeZoneWithName:@"Europe/Paris"]
properly switch between CET and CEST?
Thanks ahead!
You can use the method + (void)setDefaultTimeZone:(NSTimeZone *)aTimeZone
of the class NSTimeZone
.
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