Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

182
Vistas
Assist with auto daily? Reset time

I want to make the time auto reset according to the time zone of the area.

The problem is that when the code resets after 24 hours or one day - when it reaches 0 seconds the value returns to 24 hours but the time remains on '24 Hours'?

Although tried with 60 seconds, when the value reaches zero, it returns from 60 seconds again and a countdown is like an endless loop (this is what want but need to do it on daily basis)

Here is my code:

        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)
            }

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda