iPhone:Find the current timezone offset in HOURS

后端 未结 8 862
萌比男神i
萌比男神i 2021-02-05 03:11

How to find out the current timezone offset on the device in HOURS ?

8条回答
  •  轮回少年
    2021-02-05 03:43

    There is a very nice NSTimeZone object which will give you the timezone offset from GMT in seconds:

    float timezoneoffset = ([[NSTimeZone systemTimeZone] secondsFromGMT] / 3600.0);
    

    For more see blog post

    http://blog.indieiphonedev.com/2011/01/09/getting-the-timezone-on-the-device/

提交回复
热议问题