Last active
September 27, 2017 20:48
-
-
Save ryanemitchell/4a729d9302be7ba6f6a4cd2d00b5ad71 to your computer and use it in GitHub Desktop.
Get current hout and minutes and output based on 2 times (open and closed) Use moment.js when need more functionaality than this.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment