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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:39:17+00:00 2026-05-26T17:39:17+00:00

Hopefully this is just a quick one and I’m missing something simple… I’ve got

  • 0

Hopefully this is just a quick one and I’m missing something simple…

I’ve got an NSDateFormatter, which I’m using to convert the string 2011-11-10 into a Date object.

NSDateFormatter *fmtDate = [[NSDateFormatter alloc] init];
[fmtDate setDateFormat:@"YYYY-MM-DD"];

// input of 2011-11-10, output of 2011-01-10 00:00:00 +0000        
[appointment setDate:[fmtDate dateFromString:
  [tempAppointment objectForKey:@"date"]
]];

The return from the NSDateFormatter is stored in a managedObjectContext. My problem is that the dateFormatter is returning the date as 2011-01-10 00:00:00 +0000

Why is it reducing the month from Nobvember to January? It’s retaining the year and the day fine, but not the month.

Do I need to include the hours when I store the date? Or is it something to do with the format I set?

  • 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-26T17:39:18+00:00Added an answer on May 26, 2026 at 5:39 pm

    Your date format string is not correct using YYYY. Try yyyy-M-d or yyyy-MM-dd

    NSString *dateString = @"2011-11-10";
    
    NSDateFormatter *fmtDate = [[NSDateFormatter alloc] init];
    [fmtDate setDateFormat:@"yyyy-M-d"];
    
    NSDate *date = [fmtDate dateFromString:dateString];
    NSLog(@"date: %@", date);
    

    Outputs:

    2011-11-10 20:01:40.638 Craplet[81514:707] date: 2011-11-10 05:00:00 +0000
    

    See:

    http://unicode.org/reports/tr35/tr35-10.html#Date_Format_Patterns

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

Sidebar

Related Questions

Quick question, hopefully I am just missing something simple. Ok I have one class
I'm new to Latex so hopefully this is just a simple problem. I'm using
Hopefully this is a simple question and I have just overlooked something somewhere... I
Just a quick regex question...hopefully I have a string that looks something like this:
I have just started looking at javascript so hopefully this will be something simple.
quick question I'm struggling with, hopefully I've just got a brain-blockage and I'm missing
im struggling with syntax here: hopefully this question is v simple, im just miising
Hopefully this is a simple one, but can anyone provide some simple c# code
Hopefully this is a really quick one ;) I have written a lexer /
Hopefully this is just something easy since I'm still wet behind the ears with

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.