ryanemitchell
9/26/2017 - 2:57 PM

Between 2 times

Get current hout and minutes and output based on 2 times (open and closed)

Use moment.js when need more functionaality than this.

var d = new Date();
var hr = d.getHours();
var min = d.getMinutes();

// combine hours and minutes and convert string to number
var currenttime = parseFloat(""+ hr+min);

//set open and close times
var opentime = 830;
var closetime = 2044;


if (currenttime > opentime && currenttime < closetime) {
   //open
 
   console.log(currenttime +'\ '+'open');
    document.write('<span style=\"color:#eaea23\">OPEN</span>');
} else {
  //closed
   console.log(currenttime +'\ '+'closed');
    document.write('<span style=\"color:#eaea23\">Closed</span>');
}