I have a javascript function called showbanner() which is designed to change the src of an image based on our opening hours. It’s worked well for ages…
function showbanner() {
now = new Date();
t = now.getUTCHours();
m = now.getUTCMinutes();
if (t>9 && t<17) document.getElementById('theImg').src="/Img/Open.png";
else document.getElementById('theImg').src="/Img/Closed.png";
}
However, we’ve just changed our opening hours from 9am – 5pm to 8.30am – 5pm and I can’t for the life of me work out how to express 8.30am in the above if statement!
Could I do:
if ((t>8 && t<9 && m>30) && t<17)....
?????
Thanks in advance for any help!
Cheers,
Matt
You could make a variable which stores the time in military time format.
That could make it easier to make future changes.