Skip navigation.
 
mlInconsistencies with NSDate timeIntervalSinceReferenceDate
FROM : Dallas Brown
DATE : Thu Nov 22 02:01:13 2007

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.

Related mailsAuthorDate
mlInconsistencies with NSDate timeIntervalSinceReferenceDate Dallas Brown Nov 22, 02:01
mlRe: Inconsistencies with NSDate timeIntervalSinceReferenceDate stephen joseph but… Nov 22, 02:08
mlRE: Inconsistencies with NSDate timeIntervalSinceReferenceDate Jeff Laing Nov 22, 02:09
mlRe: Inconsistencies with NSDate timeIntervalSinceReferenceDate Dallas Brown Nov 22, 03:49