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

131
Views
Restablezca el temporizador de cuenta regresiva js y manténgalo funcionando en la actualización de la página

Quiero actualizar este código desde aquí: Restablecer temporizador de cuenta regresiva js

para restablecer cada 3 horas, pero también para seguir ejecutándose cuando el usuario vuelve a cargar la página; por ejemplo, si el usuario abre la página a las 0:2:57:00 y la actualiza en dos minutos, la cuenta regresiva debería mostrar 0:2: 55:00

Aquí está el código:

 <script> const second = 1000, minute = second * 60, hour = minute * 60, day = hour * 60; let round = 1; const diff = 180 ; // set timediff in minutes //let countDown = new Date('Mar 19, 2022 22:28:00').getTime(); let countDown = new Date(new Date('Apr 1, 2022 18:04').getTime() + diff*60000); let x = setInterval(function() { let now = new Date().getTime(); let distance = countDown - now; if (distance < 0) { const diff = 180 } document.getElementById('days').innerText = Math.floor(distance / (day)); document.getElementById('hours').innerText = Math.floor((distance % (day)) / (hour)); document.getElementById('minutes').innerText = Math.floor((distance % (hour)) / (minute)); document.getElementById('seconds').innerText = Math.floor((distance % (minute)) / second); document.getElementById('dayz').innerText = Math.floor(distance / (day)); document.getElementById('hourz').innerText = Math.floor((distance % (day)) / (hour)); document.getElementById('minutez').innerText = Math.floor((distance % (hour)) / (minute)); document.getElementById('secondz').innerText = Math.floor((distance % (minute)) / second); }, second) </script>

No sé cómo arreglarlo. ¡He buscado en todo Internet!

¡Muchas gracias por cualquier ayuda!

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!