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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:31:06+00:00 2026-06-12T21:31:06+00:00

I am given a date: 2012-10-11T23:14:00-04:00 I am using this format for NSDateFormatter to

  • 0

I am given a date:

2012-10-11T23:14:00-04:00

I am using this format for NSDateFormatter to parse:

yyyy-MM-dd'T'HH:mm:ss-ZZ

But it returns nil

  • 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-12T21:31:07+00:00Added an answer on June 12, 2026 at 9:31 pm

    Your date format is wrong. If you have a colon in the string you’re converting, you must put 5 Z characters in the format string, that is the correct usage. Also, you’d never include the +/- as part of the format, since you’re not guaranteed to only have dates + or – GMT (at least not when you’re talking about a /format/).

    So, the correct format string would be yyyy'-'MM'-'dd'T'HH':'mm':'ssZZZZZ:

    NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ssZZZZZ"];
    NSDate* date = [formatter dateFromString:@"2012-10-11T23:14:00-04:00"];
    NSLog(@"Date: %@", date); // This correctly logs Date: 2012-10-12 03:14:00 +0000
    

    Only using two Z characters would be the RFC 822 format, and your date string would have to look like: 2012-10-11T23:14:00-0400 (i.e., no hour/minute separator on the time zone offset). The timezone in your example string is ISO-8601. For more information, see: http://www.unicode.org/reports/tr35/tr35-25.html#Date_Format_Patterns

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

Sidebar

Related Questions

I want to save to database a given date with this format: date('Y-m-d H:i:s')
Is that normal that this line: echo date(Y-m-d h:m:s a, strtotime('2012-03-18 12:55:00')) gives me
Is it possible to get all 7 days for a given date using linq
Using PHP 5.3 and given the string Sat, 20 Oct 2012 05:00:00 GMT :
Need to check wether a given date is in between two given dates using
I am trying to add days to a given date using Javascript. I have
How to get year and month from a given date. e.g. $dateValue = '2012-01-05';
How can I parse a date/time string into an Access Date object given a
I want to check the given date present in from date and todate using
I wanted to get the week from the given date, for this I tried

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.