Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

176
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda