Hours in NSDate every time in 24-hour style?

前端 未结 5 1640
小鲜肉
小鲜肉 2021-02-05 16:56

I have this date formatter:

 NSDateFormatter *timeFormatter = [[NSDateFormatter alloc] init];
 [timeFormatter setDateFormat:@\"HH:mm\"];

If I u

5条回答
  •  旧时难觅i
    2021-02-05 17:17

    You have to two steps here

    NSLocale* locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_GB"];
    [formatter setLocale:locale];
    
    [formatter setDateFormat:@"hh:mm a"];
    

    here a in the formatter gives am/pm format

提交回复
热议问题