0
I’m using the Countdownjs to enter a count in my project but it is returning the incorrect day. I am using Angularjs, follows below the directive I created for counting:
.directive('tempoPercorrido', function($interval){
return {
link: function(scope, element, attrs){
var timeNow = new Date(attrs.tempoPercorrido);
var units = countdown.ALL;
var timespan = countdown(timeNow, null, units, 0, 0);
function updateTme(){
var timespan = countdown(timeNow, null, units, 0, 0);
var dias = timespan.days <= 9 ? '0' + timespan.days.toString() : timespan.days.toString();
var horas = timespan.hours <= 9 ? '0' + timespan.hours.toString() : timespan.hours.toString();
var minutos = timespan.minutes <= 9 ? '0' + timespan.minutes.toString() : timespan.minutes.toString();
var segundos = timespan.seconds <= 9 ? '0' + timespan.seconds.toString() : timespan.seconds.toString();
var contador = '<div class="dias circulo">'+ dias + '</div>'+
'<div class="horas circulo">'+ horas + '</div>'+
'<div class="minutos circulo">'+ minutos + '</div>'+
'<div class="segundos circulo">'+ segundos + '</div>';
//console.log(timespan);
$(element).html(contador);
}
updateTme();
$interval(function(){
updateTme();
}, 1000);
}
}
})
In HTML, insert the following data:
<div class="horario_banner" tempo-percorrido="2017-10-29 00:00:00"></div>
But for this date is returning 06 days 08 hours 50 min and the resulting seconds. In fact it should return more than 100 days.
If active the timespan console it returns the following data:
n {start: Sun Oct 29 2017 00:00:00 GMT-0200 (Brazilian daylight saving time), end: Wed Mar 15 2017 15:11:13 GMT-0300 (Brazilian daylight saving time), Units: 2047, value: -19640926732, millennia: 0...}
The problem I found, is in var Units, he is taking the month too, and not only the days, hours, minutes and seconds, the problem is that I do not know how to take the month and take only the days, hours, minutes and seconds.
– Maurício Krüger