2
I’m developing a website with a countdown.
The code works well on the desktop and the timer starts counting perfectly in Firefox and Chrome, but in mobile, specifically in iphone, Safari browser, the number shows Nan: Nan: Nan
Someone’s had this problem before?
I’m using the Countdown JS: http://countdownjs.org/
Follow the code below:
Directive:
.directive('tempoPercorrido', function($interval){
return {
link: function(scope, element, attrs){
var timeNow = new Date(attrs.tempoPercorrido);
var units = countdown.DAYS | countdown.HOURS | countdown.MINUTES | countdown.SECONDS;
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);
}
}
})
Html:
<div class="horario_banner" tempo-percorrido="2017-09-15 10:00:00"></div>