1 reply [Last post]
oska
oska's picture
Offline
newbie
Fremantle
Last seen: 2 years 29 weeks ago
Fremantle
Timezone: GMT+8
Joined: 2016-05-18
Posts: 1
Points: 2

I have a table with opening hours:
Monday to Thursday Friday Saturday and Sunday
7:00am - 22:00pm 7:00am to 19:00pm 9:30am to 17:30pm

have Closed DIV and an open DIV
Want hide or show the above table depending on the time.
I have done the code below but I need some pointers how to deal with the part hours 9:30 and 17:30 on the weekend
Thank you
*****************************

 <script language="javascript" type="text/javascript">
 
	$(document).ready(function () {
 
    var d = new Date();
    var dayOfWeek = d.getDay();
    var hour = d.getHours();
    var minute = d.getMinutes()
 
    // open hours Monday - Friday 9am - 5:pm = open
    if  ((dayOfWeek  >=  1 && dayOfWeek <= 4 && hour <= 7 || hour >= 22 )  
 
	 || (dayOfWeek ===  5 && hour <= 7 || hour >= 19)
 
	 || ((dayOfWeek ===  6 || dayOfweek === 0 ) &&  hour <= 9 || hour >= 17 ))      {
        $('.open').hide();
    }
    // closed any other time than above * working from 0am -9am but none other
    else {
        $('.closed').hide();
    }
 
 
});
    </script>

Tony
Tony's picture
Offline
Moderator
Brisbane
Last seen: 5 hours 24 min ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5342
Points: 2963

Hi OskaSomething like:||

Hi Oska
Something like:

|| ((dayOfWeek ===  6 || dayOfweek === 0 ) &&  
(hour <9 || (hour === 9 && minute < 30)) || 
(hour > 17 || ( hour === 17 && minute > 30)) ))