• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Inconsistencies with NSDate timeIntervalSinceReferenceDate
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Inconsistencies with NSDate timeIntervalSinceReferenceDate


  • Subject: Inconsistencies with NSDate timeIntervalSinceReferenceDate
  • From: Dallas Brown <email@hidden>
  • Date: Wed, 21 Nov 2007 18:01:13 -0700

I seem to be getting some major inconsistencies when using NSDate timeIntervalSinceReferenceDate....
Let me explain...


I have the following code:

NSTimeInterval now = [NSDate timeIntervalSinceReferenceDate];
NSLog(@"%@", [NSDate dateWithTimeIntervalSinceReferenceDate: now]);
NSLog(@"%@", [NSString stringWithFormat:@"%d", now]);

Now the first NSLog returns the correct date, however the second NSLog returns what seems to be wild numbers.
For example here is the output from a few runs:


2007-11-21 17:26:37 -0700
2060718229

2007-11-21 17:26:38 -0700
2108793912

2007-11-21 17:26:43 -0700
-2028003597

So as you can see the first 2 runs it looks somewhat ok (Seems like a huge number difference for a change of 1 second)
Then the third run, I get a WAY different number, both in it being a negative and a big difference between even just the numbers.


According to the NSDate class reference it says a negative is used to specify a date and time before the reference date of 1 January 2001, GMT.

Is this normal output?
Do I just not understand timeIntervalSinceReferenceDate?
Am I doing something wrong?

Any help would be appreciated.

Thanks.
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Inconsistencies with NSDate timeIntervalSinceReferenceDate
      • From: "stephen joseph butler" <email@hidden>
  • Prev by Date: XCode 3 Debugger bug?
  • Next by Date: Re: Inconsistencies with NSDate timeIntervalSinceReferenceDate
  • Previous by thread: Re: XCode 3 Debugger bug?
  • Next by thread: Re: Inconsistencies with NSDate timeIntervalSinceReferenceDate
  • Index(es):
    • Date
    • Thread