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 8661481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:30:29+00:00 2026-06-12T16:30:29+00:00

If I try and set the time zone arbitrarily from anywhere within the app

  • 0

If I try and set the time zone arbitrarily from anywhere within the app using the following :

[[NSCalendar currentCalendar] setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"EST"]];
NSTimeZone *tz = [[NSCalendar currentCalendar] timeZone];
NSLog(@"%@", tz);

the result of the log statement is :

America/Los_Angeles (PDT) offset -25200 (Daylight)

(which is my local timezone, i.e. [NSTimeZone systemTimeZone])

However, functionally similar code within a category on NSCalendar works fine :

[self setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"EST"]];
NSTimeZone *tz = [self timeZone];
NSLog(@"%@", tz);

and the log yields :

America/New_York (EDT) offset -14400 (Daylight)

What is going with setting the time zone for [NSCalendar currentCalendar]? The behavior is counterintuitive.

  • 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-06-12T16:30:30+00:00Added an answer on June 12, 2026 at 4:30 pm

    Simple answer: +[NSCalendar currentCalendar] isn’t returning the same instance. It is supposed to return you an instance that reflects the currently selected locale and time zone at the time that +currentCalendar is called. There are three possible reasonable behaviours:

    • It returns a new value every time.
    • It returns a cached value unless it detects that it ought to return a new value.
    • It returns a cached value, clearing it when it notices a locale/calendar change.

    Modifying the calendar is only sensible in the first case. (In the second case, previous calls to +currentCalendar will point to the same instance. In the third case, all calls to +currentCalendar will return the same instance until the user changes locale/time zone.)

    The correct way to set the app’s time zone is +[NSTimeZone setDefaultTimeZone:].

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

Sidebar

Related Questions

Every time try to set the value of any variable in my model object,
I try to set friendship to method from class GameSimulator on Player class. for
I try to set an attribute in a XML node using MSXML. IXMLDOMElement alone
I have try to set icon for my App in the xCode. In the
I need accurate time zone support in my BlackBerry app. Because it runs J2ME,
I try to create alarm app but I don't know how to set song
try to set host in dsn of pdo like this: <?php /* Connect to
I try to set a timeout on an element, fired with a jQuery plugin.
I try to set up .hgrc file: [ui] username = MyName MySecondName <mymail@gmail.com> I
When I try and set the datatable width just the table main section is

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.