i'm trying create javascript display on our website when our shop open, , when closed.
i want create if statement between 2 times, these being 8:30 , 5:30.
i'm doing following, although won't work have 2 lots of 'minutes' defined cancel each other out.
<script type="text/javascript"> var digital=new date(); var day=digital.getday(); var hours=digital.gethours(); var minutes=digital.getminutes(); // monday - open // if (day==1 && hours>=8 && minutes>=30 && day==1 && hours<=17 && minutes<=30) document.write('open today until 5:30pm'); </script>
can suggest way of achieving trying do?
how this:
if(day == 1 && hours*60+minutes >= 510 && hours*60+minutes <= 1050) { // stuff }
with 8 * 60 + 30 = 510
, 17 * 60 + 30 = 1050
.
Comments
Post a Comment