Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7592593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:56:44+00:00 2026-05-30T20:56:44+00:00

I have a TimeZone as NSString value given as GMT-09:00. All I want is

  • 0

I have a TimeZone as NSString value given as “GMT-09:00”.

All I want is to setup my NSTimeZone with this format. I tried but wasn’t able to do this. This time may vary every time so i can’t set it as static in the method

eg. i can’t do this — timeZoneForSecondsFromGMT:(-9*3600).

Also, can I convert the above format (GMT-09:00) into number of seconds anyhow??

EDIT : I just want to set the time zone to a specific GMT format. It could be anything, GMT-09:00, GMT+05:30, etc.

If it was a static value I could have used the below method for NSTimeZone.

[formatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:(-9*3600)]];

But the value “GMT-09:00” is an NSString. So everytime, I would have to break the string and get the values for Hours and minutes. Is there an easier way?????

Thanks for the help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T20:56:45+00:00Added an answer on May 30, 2026 at 8:56 pm

    have you tried something like this?

    NSString *tzStr = @"GMT-09:00";
    NSTimeZone *tz = [[NSTimeZone alloc] initWithName:tzStr];
    NSLog(@"Tz: %@", tz);
    NSLog(@"Offset: %d", [tz secondsFromGMT]);
    
    // Tz: GMT-0900 (GMT-09:00) offset -32400
    // Offset: -32400
    

    works with @"GMT+5:30" too.

    // Tz: GMT+0530 (GMT+05:30) offset 19800
    

    and then just use [formatter setTimeZone:tz];

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

datetime.datetime.utcnow() Why does this datetime not have any timezone info given that it is
Say I have the value: -5 that represents a TimeZone (GMT-5). How can I
We have NSTimeZone class that tells more about the time zone. But I want
I have a multi-timezone web application that stores all of the datetime values in
I have a NSString (ex. 2011-04-12 19:23:39), and what I did to format it
I have a timezone stored in my database in proper PHP format with: America/New_York
I have a program that uses java.util.TimeZone to produce the GMT offsets for various
I have this value +05:00 this is my code date_default_timezone_set('UTC'); echo date('H:i A P');
I have my users set their timezone in their preferences but we also attempt
I have a timezone mismatch I need to correct in a table. All dates

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.