NSdate Assuming wrong time zone

前端 未结 2 1814
有刺的猬
有刺的猬 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.

    0 讨论(0)
  • 2020-12-02 03:45

    if you are looking for India Timezone you should use: enter image description here

    0 讨论(0)
提交回复
热议问题