0

Looking for a Script that will autho refresh page on scheduled local time clock.

Twise a day. Let's say at 8AM and 8PM,

  • every day, OR
  • specific week day, cush as Mon-Fri, Mon-Wed, etc.

Notice: recently, found below code and tried this but it doesn't not work. Looking for a proper script based on above description.

    setInterval(function(){
  var dt = new Date();
  var clock_time = dt.getHours() + ":" + dt.getMinutes();
  if ( clock_time === '22:10' ) {
     location.reload();
  }
A Jax
  • 1
  • 1

1 Answers1

2

You have left out the time in setInterval.

You can set 2 times using || (OR) operator.


let interval; // Use clearInterval(interval) to stop the interval
let refreshDelay = 60000; // Every minute

function scheduledReload() {
  let dt = new Date();
  let time = dt.getHours() + ":" + dt.getMinutes();

 if(time ==='08:10' || time === '22:10') {
   location.reload();
  }
}

interval = setInterval(scheduledReload, refreshDelay);
Alex
  • 2,164
  • 1
  • 9
  • 27