I want to check whether the current time is between two time or not.
For example, I want to check if the current time is between today morning 10AM to 12PM or Tomorr
In Swift:
let componets = Calendar.current.dateComponents([.hour, .minute, .second], from: Date())
let currentHour = componets.hour
let currentMinute = componets.minute
let currentSecond = componets.second
if currentHour! < 7 || currentHour! > 21 {
print ("do something")
} else {
print ("do nothing")
}