/    Sign up×
Community /Pin to ProfileBookmark

Countdown every hour

Hello,

I’ve been searching for this on the internet but i can’t find a similar script.

I would like to count down to 10 seconds before a new hour starts, and that must loop every hour.
For example, the scripts count down till 19:59:50 and than it will count till 20:59:50, and so on..

Can someone help me with this?
Thanks in advance!

Niels

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@007JulienJun 16.2013 — Try this
[CODE]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="generator" content="PSPad editor, www.pspad.com">
<title></title>
<style type="text/css">
#cnt {display:block;width:40px;text-align:center;line-height:40px;font-size:x-large;color:#fff;background-color:#000;}
</style>
</head>
<body>
<div id="pge"><p id="cnt"></p></div>
<script type="text/javascript">

var vigilancePeriod=15;
function waitNewHour(){
var tdy=new Date(),mnt=tdy.getMinutes(),scd=tdy.getSeconds(),dlt=3600-(mnt*60+scd);
// if (window.console) console.log("délai d'attente : "+dlt+" secondes");

if (vigilancePeriod<dlt) setTimeout(waitSecond,(dlt-vigilancePeriod)*1000);
else waitSecond();
}

function waitSecond(){var tdy=new Date(),mnt=tdy.getMinutes(),scd=tdy.getSeconds(),dlt=3600-(mnt*60+scd);
// if (window.console) console.log("delta : "+dlt);
if (dlt-10<=0) document.getElementById('cnt').innerHTML=dlt;
if (vigilancePeriod<dlt) {document.getElementById('cnt').innerHTML='';waitNewHour();}
else setTimeout(waitSecond,1000);
}
waitNewHour();
</script>
</body>
</html>

[/CODE]
×

Success!

Help @floormanager 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.18,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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