javascript - Business Open/Closed text on page according to time -


i must have tried 100 variations of code , can't seem right. feel i'm walking further off playing field.

i want display message on our pages show whether our business open or closed depending on time and/or day.

here current code.

<script type="text/javascript"> var today = new date() var open = ("we're open today 9am - 5pm</span>"); var closed = ("we're closed , open again tomorrow 9am - 6pm</span>"); if (today == 0) display.innerhtml = 'closed'; if (today.gethours() >= 9 && today.gethours() < 18) {     display.innerhtml = 'open'; } else {     display.innerhtml = 'closed'; } </script> 

and html i'm using.

<div><span id="display"></span></div> 

try (see jsfiddle):

var today = new date(),     open = "we're open today 9am - 5pm",     closed = "we're closed , open again tomorrow 9am - 6pm",     display = document.getelementbyid('display');  if (today.gethours() >= 9 && today.gethours() < 18) {     display.innerhtml = open; } else {     display.innerhtml = closed; } 

html:

<div id="display"></div> 

i assume problem was displaying "open" or "closed" in div, when should displaying either "we're open today 9am - 5pm" or "we're closed , open again tomorrow 9am - 6pm". issue referencing variables open , closed strings.


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -