-
-
Save netrunn3r/6d7859bd8602ea306b09f7ff83dfc408 to your computer and use it in GitHub Desktop.
Refresh the browser and a specific time (23:00:00)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
//refresh the page at 23:00:00 | |
refreshAt(23,00,0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment