I am getting a particular string from the web service which is actually a time. So I want to check whether the string which i get from web service is in 24 hour format. I have successfully appended AM and Pm with this code:
let dateAsString = "13:15"
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "HH:mm"
let date = dateFormatter.date(from: dateAsString)
dateFormatter.dateFormat = "h:mm a"
let Date12 = dateFormatter.string(from: date!)
print("12 hour formatted Date:",Date12)
But i wish to know whether "13:15" is greater than "12:00" as this time i am getting from webservice.
Just pass the 12-hour date format and check for
nil