Andrew
Andrew

Reputation: 16051

dateWithTimeIntervalSinceNow giving silly answers

So this is the code i've got:

NSDate *myCustomDate = [NSDate dateWithTimeIntervalSinceNow:10];
NSLog(@"My custom date: %@", myCustomDate);

And it returns: My custom date: 0023-01-23 18:37:17 +0000.

Why is it giving a silly answer for the year, instead of 2011? Everything else is correct.

Upvotes: 0

Views: 2203

Answers (2)

Matthias Bauch
Matthias Bauch

Reputation: 90117

Your device is using the japanese calendar.

Goto settings/International/Calendar and change back to gregorian calendar.

Upvotes: 5

donkim
donkim

Reputation: 13137

Hmm, interesting.. I copied that code exactly and got My custom date: 2011-01-23 18:44:14 +0000, which looks correct. Perhaps your calendar is off? What do you get when you do this?

NSDate *myDate = [NSDate date];
NSLog(@"My date: %@", myDate);
NSDate *myCustomDate = [NSDate dateWithTimeIntervalSinceNow:10]; 
NSLog(@"My custom date: %@", myCustomDate);

Upvotes: 1

Related Questions