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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:49:55+00:00 2026-05-26T14:49:55+00:00

Hey everyone, I need to convert the following format into a new format using

  • 0

Hey everyone,
I need to convert the following format into a new format using NSDateFormatter. I am quite seasoned with this but for some reason I can’t remember the correct formatting information for this foramt:

‘Fri, 25 Mar 2011 10:16:00 -0700’.

I tried using this format:’aaa, dd bbb YYYY HH:MM:SS ZHHMM’ but it doesn’t work, gives me a date way in the past.

I also need to convert it into the Eastern Time Zone when creating a new date. It says ‘+0000’ but what is that normalized to?

Any help appreciated,
Thanks,
~Arash

  • 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-26T14:49:55+00:00Added an answer on May 26, 2026 at 2:49 pm

    Typically when you’re getting date strings like that, you know what locale they’re coming from, and you would take an NSDateFormatter, set its locale using setLocale:, set its date and time formatting using setDateStyle: and setTimeStyle: and then use dateFromString:. If you can’t do that because you don’t know the locale, then you can use the UNIX functions:

    struct tm  sometime;
    const char *formatString = "%a, %d %b %Y %T %z";
    strptime_l("Fri, 25 Mar 2011 10:16:00 -0700", formatString, &sometime, NULL);
    NSDate *newDate = [NSDate dateWithTimeIntervalSince1970: mktime(&sometime)];
    

    Next, you want to “convert” newDate to Eastern Time. I say “convert” because NSDates don’t contain any information about timezones—they’re just represented as a number of seconds since January 1, 2001—so the idea of conversion makes no sense. When you print out an NSDate you get it in UTC (+0000), but an NSDate is no more associated with that timezone than with any other.

    What you want to do instead is to create a dateFormatter with the right timezone and use it to output the date:

    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_UK"]];
    [dateFormatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"EST"]];
    [dateFormatter setTimeStyle:NSDateFormatterShortStyle];
    [dateFormatter setDateStyle:NSDateFormatterMediumStyle];
    NSLog(@"%@",[dateFormatter stringFromDate:newDate]);
    // Outputs 25 Mar 2011 13:16
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey everyone, I am trying to run the following program, but am getting a
Hey everyone. The following is the code that I am using to play random
Hey everyone. I'm not big into UI programming so this may be an easy
Hey everyone. Hopefully I can explain this correctly. I have some URL's which I
Hey Everyone. I'm a first time poster, but I've browsed this site a number
Hey Everyone, Sorry to bother you with this, but I'm having an issue with
Hey everyone. While I'm trying to learn some PHP and mySQL, I ran into
Hey everyone, I'm using Virtual PC and working with a virtual hard disk (*.vhd)
Hey everyone, I'm working on a widget for Apple's Dashboard and I've run into
Hey everyone, great community you got here. I'm an Electrical Engineer doing some programming

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.