Skip to content

Instantly share code, notes, and snippets.

@luelista
Created December 31, 2010 11:52
Show Gist options
  • Save luelista/760955 to your computer and use it in GitHub Desktop.
Save luelista/760955 to your computer and use it in GitHub Desktop.
<div id="countdown_silvester"
style="background:black; font-size:40pt; text-align:center;
padding: 50px 0; color: white; line-height: 1em;">
00:00:00
</div>
<script type="text/javascript">
var cdEl = document.getElementById("countdown_silvester");
var curDate = new Date();
var trgDate = new Date(curDate.getFullYear()+1, 0, 1, 0, 0, 0);
window.setInterval(function(){
curDate = new Date();
var s = parseInt((trgDate.getTime() - curDate.getTime()) / 1000);
var m = parseInt(s / 60); s -= m * 60;
var h = parseInt(m / 60); m -= h * 60;
cdEl.innerHTML = formatNumber(h, 2) + ":" + formatNumber(m, 2) + ":" + formatNumber(s, 2);
},1000);
function formatNumber(d, len) {
while (d.length<len) d = "0" + d;
return d;
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment