Hours in NSDate every time in 24-hour style?

前端 未结 5 1624
小鲜肉
小鲜肉 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:25

    If it helps anyone I have just had an issue where I want to display the time for the user in the way they have set on their device:

    let timeFormatter = NSDateFormatter()
    timeFormatter.timeStyle = NSDateFormatterStyle.ShortStyle
    //get the time from the picker
    

    The send the time to our API in 24 style:

    timeFormatter.locale = NSLocale(localeIdentifier: "en_GB")
    //get the time again
    

提交回复
热议问题