extension Date {
var _24Format: String {
let dateFormatter = DateFormatter()
dateFormatter.timeZone = TimeZone.current
dateFormatter.dateFormat = "HH:mm"
return dateFormatter.string(from: self)
}
}
expected result from this computed property when the time is 5:00 pm is 17:00 but this not the case in all devices especially iphone XR , iphone 6S , the result was 5:00 we take a lot of time to detect this issue because it didn't appear in our iphone 7+ test device ,we detect this issue by debug this issue on a real user device . by debugging we discover this up normal behavior we start search and try many different solutions and this solution solve it
extension Date {
var _24Format: String {
let dateFormatter = DateFormatter()
dateFormatter.timeZone = TimeZone(abbreviation: "EET")!
dateFormatter.locale = Locale(identifier: "en_US_POSIX")
dateFormatter.dateFormat = "HH:mm"
return dateFormatter.string(from: self)
}
}