Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Time Zone offset number in Objective-c?

How can I get the Timezone offset in Objective-C (for iPhone OS 3)?

For example, GMT -5 is US Eastern Time. I want the -5 part of it. How would I do so?

like image 486
Moshe Avatar asked Apr 09 '10 22:04

Moshe


People also ask

How do I offset my timezone?

You can get the offset of a timezone using ZonedDateTime#getOffset . Note that the offset of a timezone that observes DST changes as per the changes in DST. For other places (e.g. India), it remains fixed. Therefore, it is recommended to mention the moment when the offset of a timezone is shown.

How do I get current timezone in Objective C?

timeZone = [NSTimeZone timeZoneForSecondsFromGMT:0]; //Create a date string in the local timezone dateFormatter. timeZone = [NSTimeZone timeZoneForSecondsFromGMT:[NSTimeZone localTimeZone]. secondsFromGMT]; NSString *localDateString = [dateFormatter stringFromDate:[NSDate date]]; NSLog(@"date = %@", localDateString);

What is offset in GMT?

Purpose. The GMTOFFSET statement specifies the Greenwich Mean Time offset, which is the number of hours and minutes that the time differs from Greenwich Mean Time (also called Coordinated Universal Time, or UTC).


1 Answers

[[NSTimeZone localTimeZone] secondsFromGMT] / 3600
like image 198
Chuck Avatar answered Sep 20 '22 09:09

Chuck