开发者

dateWithTimeIntervalSinceNow giving silly answers

开发者 https://www.devze.com 2023-02-06 01:59 出处:网络
So this is the code i\'ve got: NSDate *myCustomDate = [NSDate dateWithTimeIntervalSinceNow:10]; NSLog(@\"My custom date: %@\", myCustomDate);

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消