Timer with day hour minute and second

1

I would like to know if there is any plugin to make this timer equal to this page for example:

link

If you have an example or link for consultation you would also be grateful.

    
asked by anonymous 12.05.2015 / 18:40

1 answer

2

I think something like this should work for what you need:

var data = '2016/02/28';
var falta = (new Date(data).getTime() - new Date().getTime()) / 1000;
var segundos = Math.round(falta % 60);
var minutos = Math.round(falta / 60 % 60);
var horas = Math.round(falta / 60 / 60 % 24);
var dias = Math.round(falta / 60 / 60 / 24);
var divs = document.querySelectorAll('div');

setInterval(function () {
    if (segundos == 0) {
        segundos = 60;
        minutos--;
    }
    if (minutos == 0) {
        minutos = 60;
        horas--;
    }
    if (horas == 0) {
        horas = 24;
        dias--;
    }
    segundos--;
    var contador = [dias, horas, minutos, segundos].forEach(function (parcela, i) {
        divs[i].innerHTML = parcela;
    });

}, 1000);

jsFiddle: link

Alternatively you can use the plugin that is used on the page you mentioned: link

    
12.05.2015 / 19:33