Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

172
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!