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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:51:13+00:00 2026-06-11T07:51:13+00:00

im using xcode 4.5(4G182) with iOS 6. NSDateFormatter show wrong year in iOS 6,

  • 0

im using xcode 4.5(4G182) with iOS 6. NSDateFormatter show wrong year in iOS 6, how to solve?

NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateFormat:@"YYYY-MM-dd"];
NSString *str = [dateFormatter stringFromDate:[NSDate date]];
NSLog(@"%@ == %@",str,[[dateFormatter dateFromString:str] description]);

it print out “2012-09-14 == 2011-09-13 16:00:00 +0000″

  • 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-11T07:51:15+00:00Added an answer on June 11, 2026 at 7:51 am

    YYYY is not the same as yyyy.

    According to this page which the iOS Date format page references;

    `y`: Year
    `Y`: Year (in "Week of Year" based calendars). This year designation is used in 
         ISO year-week calendar as defined by ISO 8601, but can be used in 
         non-Gregorian based calendar systems where week date processing is desired. 
         May not always be the same value as calendar year.
    

    The operative sentence being the last one. Use yyyyinstead.


    Further details on how and why the year values may deviate when using YYYY:

    The ISO week-numbering year starts at the first day (Monday) of week
    01 and ends at the Sunday before the new ISO year (hence without
    overlap or gap). It consists of 52 or 53 full weeks. The ISO
    week-numbering year number deviates from the number of the traditional
    Gregorian calendar year on a Friday, Saturday, and Sunday, or a
    Saturday and Sunday, or just a Sunday, at the start of the traditional
    Gregorian calendar year (which are at the end of the previous ISO
    week-numbering year) and a Monday, Tuesday and Wednesday, or a Monday
    and Tuesday, or just a Monday, at the end of the traditional Gregorian
    calendar year (which are in week 01 of the next ISO week-numbering
    year). For Thursdays, the ISO week-numbering year number is always
    equal to the traditional Gregorian calendar year number.

    Examples:

    Monday 29 December 2008 is written "2009-W01-1"

    Sunday 3 January 2010 is written "2009-W53-7"

    From https://en.wikipedia.org/wiki/ISO_8601#Week_dates
    (bold styling added)

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

Sidebar

Related Questions

I'm using XCode for some iOS development and the watch window for viewing STL
using xcode 4.2 and iOS 5 and have nav bar on root controller and
using XCode 3.2.6, Base SDK iOS 4.3 I set iOS Deployment Target to iOS
I was using XCode 4.2 for a bit and I hit a wrong set
Using XCode 3.2.3 (64-bit), I get following strange output. What am I doing wrong?
I am using XCode to develop a Cocoa touch application for the iOS platform
Using Xcode 4.2.1 iPad iOS 5.0.1, create a new Single View iPad project. In
I'm using Xcode 4.3.2 & iOS 5.1 simulator, and in my project I am
I'm using Xcode 4 with iOS 4.3. Xcode 4 is very buggy, not to
Using Xcode 4.2, my app runs in iOS 5.0 simulator. It runs on 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.