NSDateFormatter time format depending on Locale

后端 未结 2 1215
既然无缘
既然无缘 2020-12-19 19:03

I\'m experiencing a really strange issue that sounds more like a system bug. I want to format a date using only Hour and Minute information and, if necessary, display AM/PM

2条回答
  •  执念已碎
    2020-12-19 19:31

    Swift 3 & 4:

    extension Date {
      var localizedStringTime: String {
        return DateFormatter.localizedString(from: self, dateStyle: .none, timeStyle: .short)
      }
    }
    

提交回复
热议问题