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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:06:22+00:00 2026-05-30T04:06:22+00:00

I have this block of code to read in the ISO 8601 Date/Time specification.

  • 0

I have this block of code to read in the ISO 8601 Date/Time specification. The problem is that for some reason, the month doesn’t work. Every time I convert it month is “01”. What am I doing wrong?

NSDateFormatter *UTCDateFormat = [[NSDateFormatter alloc] init];
[UTCDateFormat setDateFormat:@"yyyy-MM-DD'T'HH:mm:ss'Z'"];
[UTCDateFormat setTimeZone:[NSTimeZone timeZoneWithName:@"UTC"]];
[UTCDateFormat setCalendar:[[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar] autorelease]];
[UTCDateFormat setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] autorelease]];
NSLog(@"%@", [UTCDateFormat dateFromString:dateString]);

So, for example, if dateString was:

@"2002-03-12T21:13:27Z" 

my output would be:

2002-01-12 21:13:27 +0000

Things I have already tried:

  • Changed MM to LL
  • Tried without setCalendar/setLocale
  • tried with ‘ around the –
  • switched position of MM around to other places. It never changes anything.
  • Looked all over SO and it appears to work for everyone else.
  • 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-30T04:06:23+00:00Added an answer on May 30, 2026 at 4:06 am

    Try this

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

    DD is the “Day of the year” not the “Day of a month”. A great source for looking up NSDateFormatter formats is this table

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

Sidebar

Related Questions

I have this block of code: users = Array.new users << User.find(:all, :conditions =>
If I have a block of code like this: def show @post = Post.find(params[:id])
Any way I can get this working? I have a block of code: <p><a
I have this block of xaml that allows the text of a hyperlink to
hey there i have this code that should save a file from sql server
So I have this block of code. Basically, I'm taking file $i, checking if
Suppose we have a code block like this : //Assuming s is a stream:
Through GDB I have determined that the segfault is occuring somewhere in this block
I Have a hidden field that contains a value and my code block within
i have this block of xslt if-else case and was wondering if there's a

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.