Skip to content

Instantly share code, notes, and snippets.

@jirihradil
Last active September 26, 2015 05:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jirihradil/d695b308578bd9d0c594 to your computer and use it in GitHub Desktop.
Save jirihradil/d695b308578bd9d0c594 to your computer and use it in GitHub Desktop.
Javascript a odpočítávání startu
<script language="JavaScript">
var timerID = null;
var timerRunning = false;
function showtime() {
today = new Date();
BigDay = new Date("october 6, 2011 10:00:00")
msPerDay = 24 * 60 * 60 * 1000 ;
timeLeft = (BigDay.getTime() - today.getTime());
e_daysLeft = timeLeft / msPerDay;
daysLeft = Math.floor(e_daysLeft);
e_daysLeft = timeLeft / msPerDay;
daysLeft = Math.floor(e_daysLeft);
e_hrsLeft = (e_daysLeft - daysLeft)*24;
hrsLeft = Math.floor(e_hrsLeft);
minsLeft = Math.floor((e_hrsLeft - hrsLeft)*60);
hrsLeft = hrsLeft;
e_minsLeft = (e_hrsLeft - hrsLeft)*60;
secLeft = Math.floor(e_hrsLeft);
secLeft = Math.floor((e_minsLeft - minsLeft)*60);
secLeft = secLeft;
Temp3='Do akce zbývá '+daysLeft+' dní, '+hrsLeft+' hodin, '+minsLeft+' minut, '+secLeft+' sekund.'
if(daysLeft < 0){Temp3='Odpočítávání skončilo!'};
document.getElementById('cas').innerHTML = Temp3;
timerID = setTimeout("showtime()",1000);
timerRunning = true;
}
var timerID = null;
var timerRunning = false;
function stopclock () {
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}
function stopClock() {
stopclock();
return;
}
function startclock () {
stopclock();
showtime()
}
document.write("<span id='cas'> </span>");
startclock ();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment