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

212
Vistas
Date getSeconds returns 0 when subtracting to another Date getSeconds
function returntime() {
  var start = new Date().getSeconds();
  var end = new Date().getSeconds();
  var totaltime = end - start;
  document.getElementById("Answer").innerHTML = totaltime;
}

The totaltime return 0 but when i put start or end it shows the output.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

There is no delay between both statements.

var start = new Date().getSeconds();
  var end = new Date().getSeconds();

See this image for debugger output

about 4 years ago · Juan Pablo Isaza Denunciar

0

You ask for seconds. The code runs faster than a second. For example, you get 9 seconds at the start and 9 seconds in the end. If you ask for the milliseconds you will see that you will have a different result.

about 4 years ago · Juan Pablo Isaza Denunciar
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