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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:31:07+00:00 2026-05-29T06:31:07+00:00

I have the following code. When I run it on my iOS 3.1.3 device

  • 0

I have the following code. When I run it on my iOS 3.1.3 device (get over it!) it works as expected, but when I run it on the simulator (iOS 5 and 4.3) it is 1 minute and 15 seconds off (9:01:15). Is this because of my code, a bug in the simulator or a bug in iOS 4+?

NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *components = [calendar components:(NSHourCalendarUnit | NSMinuteCalendarUnit) fromDate:[NSDate date]];
components.hour = 9;
components.minute = 0;
NSDate *date = [calendar dateFromComponents:components]; // <-- date is off on simulator

Thanks for your help!

  • 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-29T06:31:07+00:00Added an answer on May 29, 2026 at 6:31 am

    I don’t fully understand why this is the case, but this happens when you use dateFromComponents: to create dates from a very long time ago. Specifically, the cutoff seems to be December 1, 1847. Anything earlier than 12am on that day seems to end up being 1
    minute 15 seconds off.

    In your case this is happening because if you only set components.hour and components.minute, you’re getting a date from January 1st, 1AD.

    If you set the year, month, and date to something more recent, like this:

    components.year = 2012;
    components.month = 2;
    components.day = 6;
    

    Then you’ll get the right output (what I got in iOS simulator):

    2012-02-06 09:00:00 +0000
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code I want to run, but the problem is $this->type
I have the following code to run python and get the result in scratch
I have following code snippet that i use to compile class at the run
Let's say that I have the following code that's run in one thread of
I have the following code, which is run every 10ms as part of a
I have the following sample code which doesn't seem to want to run. import
I have a line of code that gets the following error when run through
I have the following code which should make drawFrame be called every frame but
I have the following code to run a process on a remote machine from
I have tried to run the following code, as a proof of concept, and

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.