Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show DIV during specific times of the day (eg., during store "open hours")

I need to toggle DIV visibility based on time so my site shows when my physical store is open.

For example:
- 07:00-15:59 = Show div
- 16:00-06:59 = Hide div

Thanks!

like image 919
Tomislav Brtan Avatar asked Jun 11 '15 09:06

Tomislav Brtan


1 Answers

Here is a basic example.

//gets the current time. 
var d = new Date();
if(d.getHours() >= 7 && d.getHours() <= 15 ){
    $(".open").show();
    $(".closed").hide();
}
else {  
     $(".closed").show();
    $(".open").hide();
}

https://jsfiddle.net/16mnrL3b/

like image 75
Pushkar Newaskar Avatar answered Sep 29 '22 18:09

Pushkar Newaskar