How can I run different scripts based on time? [closed]

var hour = new Date().getHours(); // hour will get current hour like 0 to 23
switch(hour) {
case '6': // code in this case will run if current time is in 6am to 7am
alert('hi, it's in 6 a.m to 7 a.m now');
break;
case '7': // any other hour
// add your code you want to run between 7 - 8 am
break;
}

Leave a Comment