8

What is the difference between [NSTimeZone localTimeZone] and [NSTimeZone systemTimeZone]?

EmptyStack
  • 51,274
  • 23
  • 147
  • 178
  • possible duplicate of [iPhone - Differences among time zone convenience methods](http://stackoverflow.com/questions/5985468/iphone-differences-among-time-zone-convenience-methods) – jscs Jun 25 '11 at 17:52
  • 1
    possible duplicate of [NSTimeZone: what is the difference between localTimeZone and systemTimeZone?](http://stackoverflow.com/questions/1526990/nstimezone-what-is-the-difference-between-localtimezone-and-systemtimezone) – wallyk Mar 16 '12 at 19:59

2 Answers2

22

According to the NSTimeZone reference of iOS, the systemTimeZone represents the timezone used by the system (device) itself.

The localTimeZone returns an object that represents the current default time zone for the application. The application can change its default timezone via the setDefaultTimeZone call.

There are no exposed Cocoa APIs to change the system time zone, or to change another application's time zone.

Mat
  • 202,337
  • 40
  • 393
  • 406
4

If you have a object instantiated from the [NSTimeZone systemTimeZone], it will be cached by the application and will not reflect the current device's zone until you clear it using [NSTimeZone resetSystemTimeZone].

Use [NSTimeZone localTimeZone] instead of [NSTimeZone defaultTimeZone] if you want your timezone variable to reflect any updates to the application's timezone.

Vivek Molkar
  • 3,910
  • 1
  • 34
  • 46
Vivi
  • 41
  • 1