iPhone NSDateFormatter Timezone Conversion

前端 未结 6 1315
终归单人心
终归单人心 2020-12-03 01:15

I am trying to create a formatter that will convert the date format shown to an NSDate object:

NSString *dateStr = @\"2010-06-21T19:00:00-05:00\";
NSDateForm         


        
6条回答
  •  情话喂你
    2020-12-03 01:25

    Honestly, you'll just have to change the source data (removing the colon) before running it through the formatter. Your original date string is non-standard and none of the time zone format strings will work properly on it.

    You can see the valid inputs on unicode.org.

    ZZZ e.g. "-0500"

    ZZZZ e.g. "GMT-05:00"

    Nothing for "-05:00"

提交回复
热议问题