NSDateFormatter not giving me correct

后端 未结 1 1733
情话喂你
情话喂你 2020-12-20 10:15

I am displaying time. It will show me :TIME :2012-06-18 23:00:00 +0000 But after using NSDateFormatter I do not know why it is giving me 00:00:00 AM

NSDa         


        
相关标签:
1条回答
  • 2020-12-20 10:50

    Your first NSLog outputs the date in GMT time (notice the trailing +0000). An NSDateFormatter object will format the date to the specified time zone. Your NSLog statements show that the stored date in self.startDate is exactly 00:00:00 AM in at least one time zone, and the formatter is set to that time zone. The formatter will default to the time zone for the device. You could set the formatter's timezone to 0 seconds from GMT to see 23:00:00 PM out of your last NSLog statement:

    [dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
    
    0 讨论(0)
提交回复
热议问题