NSdate Assuming wrong time zone

前端 未结 2 1846
有刺的猬
有刺的猬 2020-12-02 02:45

I am trying to convert the following string into an NSDate object:

NSString *str=@\"25 May 2012 10:25:00\";

NSDateFormatter *dateFormatter = [[[NSDateFormat         


        
2条回答
  •  借酒劲吻你
    2020-12-02 03:41

    When you see an [NSDate description] printed in the console, it is always the corresponding time in GMT. If you use the same date formatter to convert the date back to a string, it should be in the specified time zone.

    An [NSDate description] is what you see if you type

    po date
    

    or

    po [date description]
    

    or you use NSLog to send either one of these forms to the console.

提交回复
热议问题