I have list array of data times in json from website so i need convert time from 24 hours system to 12 hours and use times to make Compared with current time
this my code :-
let task=URLSession.shared.dataTask(with: url!) {(data, response, err) in
if err != nil{
print("err")
}else{
do{
let dataT=try JSONSerialization.jsonObject(with: data!, options: JSONSerialization.ReadingOptions.mutableContainers) as? NSDictionary
if let prayTime = dataT?["times"] as? NSArray {
if let fajerTT = prayTime[0] as? String {
let timeFormat = DateFormatter()
timeFormat.dateFormat = "hh:mm"
let timeFajer=timeFormat.date(from: fajerTT)
print(fajerTT)
print("\(timeFajer))")
self.fajerT.text=timeFajer
}else {print("false")}
}
}catch{print("Error")
}
}
}
task.resume()
and this from json
["05:05","06:30","12:56","16:30","19:21","19:21","20:51"]}