I am using Luxon and passing different timezones via html code. I want to store current time in variable and to check time is in range or not. I have three times. One for opening office time, lunch time and last closing time.
For instance Opening time : 09:15 to 12:59 pm Lunch Time : 01:00 Pm to 02:00 Pm Closing time : 02:01 pm to 4:30 pm
When time fall in this ranges, status get automatically change (Open, Lunch, Close)
With hour only not helping, i need whole time in current date.
Kindly help me. Any type of guidance would be appreciated.
const locations = document.querySelectorAll("section.Timezone div")
const updateTimes = function () {
locations.forEach(location => {
const output = location.querySelector("output")
const timezone = location.getAttribute("Country_Timezone")
const now = luxon.DateTime.now().setZone(timezone)
output.innerHTML = now.toFormat("HH:mm:ss")
const hour = parseInt(now.toFormat("H"))
if(hour >=9 && hour <18)
{
location.classList.add("open")
}
})
}
updateTimes()
setInterval(function () {
updateTimes()
}, 1000)`