Basic count down – Contador Regresivo básico – Javascript – Snippet

<style>
#countdown {
color: #660000;
font-size: 20px;
font: bold;
}
</style>

<script>

CountDownTimer(’09/02/2013 10:1 AM’, ‘countdown’);

function CountDownTimer(dt, id)
{
var end = new Date(dt);

var _second = 1000;
var _minute = _second * 60;
var _hour = _minute * 60;
var _day = _hour * 24;
var timer;

function showRemaining() {
var now = new Date();
var distance = end – now;
if (distance < 0) {

clearInterval(timer);
document.getElementById(id).innerHTML = ‘Aguarde nossa nova edição’; // Acabou

return;
}
var days = Math.floor(distance / _day);
var hours = Math.floor((distance % _day) / _hour);
var minutes = Math.floor((distance % _hour) / _minute);
var seconds = Math.floor((distance % _minute) / _second);

document.getElementById(id).innerHTML = days + ‘D -‘;
document.getElementById(id).innerHTML += hours + ‘:’;
document.getElementById(id).innerHTML += minutes + ‘:’;
document.getElementById(id).innerHTML += seconds + ”;
}

timer = setInterval(showRemaining, 1000);
}

</script>
<div id=”countdown”></div>

Deixe uma resposta


oito − = 4