JSFiddle - React, Tailwind, and code Playground

by ryan113

HTML

<p>Enter Time to start dashboard</p>
<p>Hour</p>
<input id="strthour">
<p>Minute</p>
<input id="strtmin">
<button onclick="setTime()">Submit</button>

JavaScript

var hr = 06;
var mn = 00;

function setTime() {
  hr = strthour.value;
  mn = strtmin.value;
}

window.setInterval(function(){ // Set interval for checking
    var date = new Date(); // Create a Date object to find out what time it is
    // Check the time
    if(date.getHours() === hr && date.getMinutes() === mn && date.getSeconds() === 0){
        alert("it worked")
    }
}, 10000); // Repeat every 60000 milliseconds (1 minute)