Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone:Find the current timezone offset in HOURS

Tags:

iphone

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

like image 412
Getsy Avatar asked Apr 13 '11 08:04

Getsy


People also ask

How do you find time zone offset?

The JavaScript getTimezoneOffset() method is used to find the timezone offset. It returns the timezone difference in minutes, between the UTC and the current local time. If the returned value is positive, local timezone is behind the UTC and if it is negative, the local timezone if ahead of UTC.

Does timezone offset change?

An offset is the number of hours or minutes a certain time zone is ahead of or behind GMT**. A time zone's offset can change throughout the year because of Daylight Saving Time.

What is time zone in Swift?

UTC Date Format Use DateFormatter to parse and format a date in Swift. The default time zone for a DateFormatter is the device's local time, so to obtain UTC time the timeZone value needs to be configured. let utcDateFormatter = DateFormatter() utcDateFormatter. dateStyle = . medium utcDateFormatter.


1 Answers

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/

like image 177
Jhaliya - Praveen Sharma Avatar answered Sep 24 '22 01:09

Jhaliya - Praveen Sharma