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

  • Home
  • SEARCH
  • 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 7899961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:50:42+00:00 2026-06-03T08:50:42+00:00

I have a function which converts an NSString in RFC3339 to NSDate using an

  • 0

I have a function which converts an NSString in RFC3339 to NSDate using an NSDateFormatter, but I don’t know how to take account of the timezone doing the reverse.

The relevant part of the string to NSDate conversion is:

    // The result of a call to systemTimeZone is cached by the app automatically, if the user changes it that change isn't 
    // reflected unless resetSystemTimeZone is called to clear the cache.
    [NSTimeZone resetSystemTimeZone]; 
    NSLocale *enUSPOSIXLocale;
    enUSPOSIXLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
    [sRFC3339DateFormatter setLocale:enUSPOSIXLocale];
    if ([fromString hasSuffix:@"Z"] || [fromString hasSuffix:@"z"])
    {
        [sRFC3339DateFormatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
    }
    else 
    {
        [sRFC3339DateFormatter setTimeZone:[NSTimeZone systemTimeZone]];
    }

[sRFC3339DateFormatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'"];

My question is, when converting in the other direction from an NSDate to an NSString, how do I know what to call setTimeZone with? When going from string to NSDate its by looking at the absense/presense of Z. But if I have an NSDate how do I know what time zone to set the formatter to?

  • 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-03T08:50:43+00:00Added an answer on June 3, 2026 at 8:50 am

    Your NSDate is stored as UTC/GMT timezone. So when you are converting that to a string, you pick the time zone you want the string displayed in. There is no “right” answer. It’s whatever you want to display.

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

Sidebar

Related Questions

I have function which converts a 1D list to a 3D list, but at
i have a function that converts an array to a hash which i would
I have a function which converts seconds to the format of Hours:Minutes:Seconds function sec2hms
I have a DLL which has a function which accepts a function pointer converts
i have written a code which converts date and time into timezone , now
I have a SQL Server function which converts a nvarchar day duration setting into
I have a function which converts all of the strings to datetime. ALTER FUNCTION
I have the following as3 function below which converts normal html with links so
I have matlab function that calls a Perl script which converts a large text
hi i have function which is called by tinker listbox so i cannot return

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.