0

This is what I've already tried:

<meta name="Refresh" content="3600">

What would be the best way to go about making a HTML page automatically refresh at 12am PT every day? Or if that's not possible, the top of every hour like 1am, 2am, 3am and so on. Not an hour from when the user loads the page but the top of the next hour.

Everything I've tried so far seems to just refresh every hour from when the page was loaded.

Clonkex
  • 3,373
  • 7
  • 38
  • 55
  • Possible duplicate of [How to automatically reload a web page at a certain time?](https://stackoverflow.com/questions/1217929/how-to-automatically-reload-a-web-page-at-a-certain-time) – gabrielchl Jun 23 '17 at 03:48
  • that goes off the users timezone tho. i need it to refresh at the top of every hour regardless of timezones –  Jun 23 '17 at 04:03

2 Answers2

4

You can't do this with HTML alone. You need Javascript, but it's very easy. Just add this to your HTML:

<script>
    var current = new Date();
    var future = new Date();
    future.setTime(future.getTime() + 3600000); //3600000 = 1 hour
    future.setMinutes(0);
    future.setSeconds(0);

    var timeout = (future.getTime() - current.getTime());
    setTimeout(function() { window.location.reload(true); }, timeout);
</script>
Clonkex
  • 3,373
  • 7
  • 38
  • 55
  • Will that Reset at the top of every hour or 1 hour from when the user first loads the page? like lets say they load the page at 12:36 pm i need it to refresh at 1 pm not 1:36 pm –  Jun 23 '17 at 04:08
  • @BryanSMith This code should refresh at the top of the next hour, so if the user loads the page at 12:36pm it will refresh at 1:00pm, then 2:00pm and so on. – Clonkex Jun 23 '17 at 04:12
  • @BryanSMith No worries, glad to help. Don't forget to accept this as the correct answer if it solves your problem :) – Clonkex Jun 23 '17 at 04:19
1
<META HTTP-EQUIV="refresh" CONTENT="3600">

Add this to your head.

Joe Neuman
  • 115
  • 1
  • 8