Automatically reload the page at certain times

1

I need a code for web (Wordpress) that forces the reload of only the homepage of the site at a certain time, this for all users, for example at 6:10 p.m.

    
asked by anonymous 28.07.2017 / 23:20

1 answer

1

Please try the Javascript below:

function refreshAt(hours, minutes, seconds) {
var now = new Date();
var then = new Date();

if(now.getHours() > hours ||
   (now.getHours() == hours && now.getMinutes() > minutes) ||
    now.getHours() == hours && now.getMinutes() == minutes && now.getSeconds() >= seconds) {
    then.setDate(now.getDate() + 1);
}
then.setHours(hours);
then.setMinutes(minutes);
then.setSeconds(seconds);

var timeout = (then.getTime() - now.getTime());
setTimeout(function() { window.location.reload(true); }, timeout);
    
28.07.2017 / 23:35