dslreports logo
site
 
    All Forums Hot Topics Gallery
spc

spacer




how-to block ads


Search Topic:
uniqs
778
share rss forum feed


IllIlIlllIll
EliteData
Premium
join:2003-07-06
Hampton Bays, NY
kudos:7

Javascript reload at specific time

hi.
im wondering if anyone could post the code snippet for the following:
i need to have script added to my index page to reload the page at the top and bottom of every hour (every half hour) but using the current PC time.
example:
at the top of every hour (9:00pm, 10:00pm, 11:00pm, etc) and bottom of every hour (9:30pm, 10:30pm, 11:30pm, etc)
a simple timer script would work but the timer has to start with the current PC time so that the page is reloaded at the correct time (every 30 minutes on the top and bottom of every hour) otherwise the page would reload before/after the top & bottom of every hour.
if i used a simple timer script, the page would have to be loaded at the top or bottom of every hour to operate correctly.
thanks !
--
Suffolk County NY Police Feed - »www.scpdny.com
PS3 Gaming Feed - »www.livestream.com/elitedata


sbconslt

join:2009-07-28
Los Angeles, CA
Use the Date object and getMinutes() method.

var d = new Date();
var m = d.getMinutes();

m is going to contain a value between 0 and 59.

Do a little arithmetic and set your timer accordingly.
--
Scott Brown Consulting


IllIlIlllIll
EliteData
Premium
join:2003-07-06
Hampton Bays, NY
kudos:7
said by sbconslt:

Use the Date object and getMinutes() method.

var d = new Date();
var m = d.getMinutes();

m is going to contain a value between 0 and 59.

Do a little arithmetic and set your timer accordingly.

thank you
--
Suffolk County NY Police Feed - »www.scpdny.com
PS3 Gaming Feed - »www.livestream.com/elitedata