I am using an API to get a list of times which is five times a day as string in (AM,PM) format without date,
("4:30 AM","1:00 PM","3:20: PM","6:40 PM","9:10 PM")
what I am trying to do is to show the next time in the screen depends on the current time on the iPhone
so if the time now is 5:00 PM the time should display on the screen is 6:40 PM
how can I compare times in swift without including the dates because I tried to convert the list of times I have to Date type but unfortunately am getting dates and the dates shows in 2001 so even if I try to compare the date would give me wrong result
print(self._praytime.arraytime)
for Dates in self._praytime.arraytime {
let dateformatters = DateFormatter()
dateformatters.dateStyle = .none
dateformatters.timeStyle = .short
let xxbbs = dateformatters.date(from: Dates)
print(xxbbs!)
}
after I got the times I put it in Array and I tried to execute the code upper so I can get the times without the date but what shows in the output screen was this
Optional(2000-01-01 11:14:00 +0000)
Optional(2000-01-01 20:06:00 +0000)
Optional(1999-12-31 23:57:00 +0000)
Optional(2000-01-01 03:11:00 +0000)
Optional(2000-01-01 04:41:00 +0000)
any idea how to solve this problem and if is there any other easy way to do this task I'm exciting to hear it
thank you all