NSDate Output incorrectly [duplicate]

前提是你 提交于 2019-12-02 13:27:21
VikingoS says Reinstate Monica

because the timezone, where your device is located, is UTC-7.

The output is in UTC (hence the +0000), as a single NSDate will always print out it's time in UTC.

If you use an NSDateFormatter to output the date, it will take your locale in account. See my answer here: NSDate date method returns wrong result

These are correct results. When you use NSLog to output an NSDate object, it displays in GMT. The parsing was done in your local timezone. NSDate objects are alway in GMT. If you want to print the NSDate object in your local timezone then you need an NSDateFormatter to print the date.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!