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.
Your device is using the japanese calendar.
Goto settings/International/Calendar and change back to gregorian calendar.
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);
精彩评论