Showing a certain information at a specific time or day.
I pretty new to jquery and have my code currently working such that it assumes that the shop is open every day of the week from 9-8pm. Any help is appreciated, thanks
However, how can I tweak my code such that the opening hours are:
- Sunday: Close
- Monday: 6pm to 10pm
- Tuesday: 6pm to 10pm
- Wednesday: 6pm to 10pm
- Thursday: 11am to 10pm
- Friday: 11am to 10pm
SCRIPT:
var data = [
[0, 9, "Sorry we are closed."],
[10, 20, "We are open."],
[21, 24, "Sorry, we are closed."]
],
hr = new Date().getHours();
for(var i=0; i<data.length;i++){
if(hr >= data[i][0] && hr <= data[i][1]){
$("#open_close").html(data[i][2]);
break;
}
};
HTML:
<div class="time"><a href="#contact">
<img id="clock" src="assets/clock.png">
<div id="open_close"></div></a>
</div>