NSDateFormatter difference

后端 未结 2 1743
日久生厌
日久生厌 2021-01-27 18:06

What is the difference between these two Date Formats. First one give actual time but second on give time buy adding time zone offset value.

NSDateFormatter * d         


        
相关标签:
2条回答
  • 2021-01-27 18:27

    The problem with the 2nd format is all of the needless quotes, especially around the Z. By quoting the Z this means the Z is treated as a literal character and not the timezone format specifier.

    Get rid of the quotes around the Z and both will give the same result.

    0 讨论(0)
  • 2021-01-27 18:39

    The second date formatter is incorrect, the 'Z' should not be single quoted, that keeps it from being considered a format character.

    Also the only single quotes that are needed are around the 'T' so that is is not considered a format character but rather a literal.

    See ICU User Guide: Formatting Dates and Times

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