NSDateFormatter not working properly?

后端 未结 2 1750
误落风尘
误落风尘 2021-01-28 05:02

My code ,

-(NSString *)trimDateStringInRequiredFormat:(NSString *)dateInString{
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFor         


        
相关标签:
2条回答
  • 2021-01-28 05:37

    try doing:

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

    With hh you have the 12h format, with HH you use 24h format

    0 讨论(0)
  • 2021-01-28 05:40

    This is because for 24 Hr format you need to use HH instead of hh

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