I thought I saw something answering this on SO recently but now I can\'t find it. Here is the code I am using now to determine if settings are for 24 hour time display. It
I my case I simply set timeStyle = .short for dateFormatter. (Swift)
let yourCustomDate = Date()
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "hh:mm a"
dateFormatter.amSymbol = "am"
dateFormatter.pmSymbol = "pm"
dateFormatter.timeStyle = .short
dateFormatter.timeZone = TimeZone(secondsFromGMT: 0)
let dateString = dateFormatter.string(from: yourCustomDate)
As result, dateString will be automatically converted to 12 or 24 time format. For example: 6:30 pm in 12-hours format and 18:30 in 24-hours format.