Quiero hacer que la hora se reinicie automáticamente de acuerdo con la zona horaria del área.
El problema es que cuando el código se restablece después de 24 horas o un día, cuando llega a 0 segundos, el valor vuelve a 24 horas pero el tiempo permanece en '24 horas'.
Aunque se probó con 60 segundos, cuando el valor llega a cero, regresa nuevamente desde los 60 segundos y una cuenta regresiva es como un bucle sin fin (esto es lo que quiero pero necesito hacerlo a diario)
Aquí está mi código:
let na; setInterval(function(){ na = moment().tz("America/New_York").format("hh:mm A"); //i used this pkg 'moment' to take the time in a region and i want it to check with setInterval to update the time every seconds because that's the only way i know to take the time of a country //day = check.format('dddd'); i just removed this part cuz i need it later }) let timer1; // i put this because want to share value in embed try { //na let NAtime = setInterval(checkNA); async function checkNA() { //if(na === timeResetNA) { i removed this part just to check if return to zero it returns to its own value and then completes the counting timer1 = circleTimeDailyNA; console.log('na done') // countdown start a day! nacountDown = setInterval(function () { timer1 -= 1; console.log('na1: ' + timer1); if (timer1 <= 0){ clearInterval(nacountDown); timerend1 = setInterval(function(){ console.log('daily gone!') timer1 = circleTimeDailyNA; // reset to 1day clearInterval(timerend1) reCheckTimerNA(); }) } },1000) clearInterval(NAtime) //} } function reCheckTimerNA() { console.log('the function passed to recheck.') NAtime = setInterval(checkNA); // will make countdown again }; } catch(err) { console.log(err) }