/    Sign up×
Community /Pin to ProfileBookmark

okay,
I want a script that keeps on checking the time and when it hits exactly 2 pm, and 4am, it opens a site.

Anyone know how?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@GollumMay 20.2003 — What you could do is work out which of 2pm and 4am comes next, work out how long it is till then, and then set a timeout to wait for it. e.g.

function Go()

{

window.location = "http://somwhere.else.com";

}

function OnLoad()

{

var d = new Date();

var h = d.getHours();

var t = new Date();

if ( h < 4 ) t.setHours(4);

else if ( h < 14 ) t.setHours(14);

else

{

t.setHours(4);

t.setTime(t.getTime() + 86400000); // tomorrow

}

var ms = t.getTime() - d.getTime();

window.setTimeout("Go();", ms);

}
Copy linkTweet thisAlerts:
@viciousauthorMay 21.2003 — thanks

but i was looking for something that I could add add times down to the half-hour

Also, i was wondering how i could have a text that reads:

Next opening: hh:mm:ss

thanks anyway
×

Success!

Help @vicious spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...