ryanemitchell
9/26/2017 - 2:32 AM

JS Bin Display if opened and cloved // source http://jsbin.com/wufote

JS Bin

Display if opened and cloved

// source http://jsbin.com/wufote

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 time
var opentime = 830;
var closetime = 2300;


if (currenttime => opentime && currenttime <= closetime) {
   //open
   console.log('open');
} else {
  //closed
  console.log('closed');
}
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Display if opened and cloved">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>

<script id="jsbin-javascript">
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 time
var opentime = 830;
var closetime = 2300;


if (currenttime => opentime && currenttime <= closetime) {
   //open
   console.log('open');
} else {
  //closed
  console.log('closed');
}
</script>



<script id="jsbin-source-javascript" type="text/javascript">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 time
var opentime = 830;
var closetime = 2300;


if (currenttime => opentime && currenttime <= closetime) {
   //open
   console.log('open');
} else {
  //closed
  console.log('closed');
}
</script></body>
</html>