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

97
Vistas
Moment countdown timer. Difference between two timestamps with finish condition. JavaScript

When I run the below it shows the countdown as expected and starts counting down. But when the countdown hits 0 it resets at 59:00 and my text "Expired" does not show.

I am wanting to show a countdown clock in mm:ss for the difference between "now" and "exam_end_time" timestamps. Once it completes it should full stop and the text should display.

Where the time now is 15:01:00 - The countdown time should start at 04:00

<div id="demo"></div>

<script>
var diff = document.getElementById('demo');
var now = moment.utc().format("YYYY-MM-DD HH:mm:ss");
var input_time = '2022-07-01 15:00:00';
var exam_end_time ='2022-07-01 15:05:00';

var mins = moment.utc(moment(exam_end_time, "HH:mm"),diff(moment(now, "HH:mm"))).format("mm")
var frequency = mins*60
var refreshIntervalId = setIntervan(() => {
   const formatted = moment.utc(frequency--*1000.format("mm:ss");
      diff.innerHTML = formatted;
}, 1000;


// When countdown hits zero. Stop the clock and show "Expired"

setTimeout(() => {
   if(mins === ) {
      diff.innerHTML = "Expired";
      clearInterval(refreshIntervalId);
}},frequency*1000;
</script>
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