Why my NSDateFormatter returns null?

后端 未结 2 1877
[愿得一人]
[愿得一人] 2020-12-07 03:23

Why my NSDateFormatter returns null? Here is my code:

  NSString *dateString = @\"21-12-2012 11:05:15\";
  NSDateFormatter *dateFormatter = [[NSDateFormatter         


        
相关标签:
2条回答
  • 2020-12-07 03:55

    Use HH instead of hh.

    hh usually is 12 hour time while HH is usually 24 hour time.

    [dateFormatter setDateFormat:@"dd-MM-yyyy HH:mm:ss"];
    

    A good official reference for this, as linked by Apple themselves, is here. Another good table is here, as mentioned by Zaph.

    0 讨论(0)
  • 2020-12-07 04:18

    You should use

    [dateFormatter setDateFormat:@"dd-MM-yyyy HH:mm:ss"];
    
    0 讨论(0)
提交回复
热议问题