[英]NSDate get the values one day before today
I try to get date today using this code: 我尝试使用以下代码获取日期:
NSDate *today = [[NSDate alloc] init];
NSLog(@"Today: %@", today);
the result is: 结果是:
January 30, 2013 +00:00:00 2013年1月30日+00:00:00
But the current date is 但是当前日期是
January 29, 2013 +00:00:00 2013年1月29日+00:00:00
Any idea, to how solve this case? 任何想法,如何解决这种情况?
Why not just 为什么不只是
NSDate* today = [NSDate date];
Also, remember that if you look at "today" you will see the date in GMT, not your local time. 另外,请记住,如果您查看“今天”,则会看到格林尼治标准时间的日期,而不是当地时间。
OK, here are two things to check out: 好的,这有两件事要检查:
Ingo. 英戈
Try This: 尝试这个:
NSLog(@"Today: %@",[today descriptionWithLocale:[NSLocale currentLocale]];
NSDate
returns date in GMT
.Above will convert date in your currentLocale
. NSDate
以GMT
返回日期。以上将日期转换为您的currentLocale
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.