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

The Archive Base Latest Questions

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

I develop an app that needs to get the current week. I tried this:

  • 0

I develop an app that needs to get the current week. I tried this:

- (void)viewDidLoad
{
    [super viewDidLoad];
    NSString *dateString = @"1-1-2011";
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"dd-MM-yyyy"];
    NSDate *dateFromString = [[NSDate alloc] init];
    dateFromString = [dateFormatter dateFromString:dateString];
    NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
    NSDateComponents *comp = [gregorian components:NSWeekCalendarUnit fromDate:dateFromString];
    NSLog(@"%d", comp.week);

    [dateFormatter release];
}

but it shows me 52. Which is actually a wrong result. Please, suggest me any ideas.
Thanks in advance.

  • 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-26T10:19:55+00:00Added an answer on May 26, 2026 at 10:19 am

    The week date depends on which numbering standard is in use. For instance, the ISO-8601 standard defines week 1 of a year as “the week with the year’s first Thursday in it”.

    The first of January 2011 was a Saturday, which means the following week was week 1 of 2011, making the week 27.12.2010–2.1.2011 week 52 of 2010.

    Also, there’s several incompatible standards for when weeks start or end and how weeks in a year are numbered. This makes week numbers a confusing way to specify a date range and the best solution to avoid using them.

    From the documentation to NSCalendar, it seems you could also use setMinimumDaysInFirstWeek: to adjust the way it numbers weeks.

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

Sidebar

Related Questions

I'm hearing this alot, that you can develop an app in WPF and run
I need to develop an app that runs side by side with a django-app.
I need to develop a point of sale app that will be used on
I want to develop an enterprise app that includes a WindowsForms presentation layer, middle-tier
I am going to develop an app based on google map. In that locations
I'm looking to develop/obtain a simple GMaps app for my site that lets the
I am planning to develop a pretty awesome new web app that has a
I'd like to develop an app for multiple clients that displays analytics data specific
I am designing a web app that has some information that needs to be
I am looking to develop an app that will take login details from the

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.