简体   繁体   English

NSDate的时间不正确

[英]Incorrect time with NSDate

I have copied the following code from 我从中复制了以下代码

get time and date by NSDate 通过NSDate获取时间和日期

to get the current time and date for my app. 获取我的应用程序的当前时间和日期。

I am unsure on how to set the correct time on my xcode but the time is always 12 hours behind. 我不确定如何在我的xcode上设置正确的时间,但时间总是落后12个小时。

This happens on both the simulator and my device. 这在模拟器和我的设备上都会发生。

Has anyone else experienced the same bug/situation/problem? 有没有其他人遇到过同样的错误/情况/问题?

Thanks 谢谢

Jdi, You are absolutely right. 杰迪,你是对的。

I just had moment where I realised the time was only 11 hrs behind and not 12. 我刚刚意识到时间只落后了11个小时而不是12小时。

For anyone as stupid as I am, I have found a solution on another site. 对于像我一样愚蠢的人,我在另一个网站上找到了解决方案。

http://buildingmyworld.wordpress.com/2011/04/13/get-local-time-from-iphone-local-nsdate/ http://buildingmyworld.wordpress.com/2011/04/13/get-local-time-from-iphone-local-nsdate/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM