Hours in NSDate every time in 24-hour style?

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

I have this date formatter:

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

If I u

5条回答
  •  臣服心动
    2021-02-05 17:36

    I had this same issue recently and came across this document which lists all the date format patterns: http://unicode.org/reports/tr35/tr35-6.html#Date_Format_Patterns

    I was able to get 24-times working just by using k:mm as the date format:

    NSDateFormatter *format = [[NSDateFormatter alloc] init];
    [format setDateFormat:@"k:mm"];
    

提交回复
热议问题