I'm using Countdownjs to insert a count in my project but it is returning the wrong day. I'm using AngularJS, here's the directive I created for the count:
.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, I enter the following data:
<div class="horario_banner" tempo-percorrido="2017-10-29 00:00:00"></div>
But for this date it is returning 06 days 08 hours 50 min and the resulting seconds. Being that it should actually return more than 100 days.
If the timespan console is active it returns the following data:
n {start: Sun Oct 29 2017 00:00:00 GMT-0200 (Brazilian Daylight Time), end: Wed Mar 15 2017 15:11:13 GMT-0300 (Brazil's official time), units: 2047 , value: -19640926732, millennia: 0 ...}