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

100
Vistas
Why are we dividing the the difference of dates by 1000?
var newYear = "1 jan 2022";

function countDates() {
  var newYearDate = new Date(newYear);
  var currentDate = new Date();
  const days = Math.floor((newYearDate - currentDate) / (1000*60 * 60 * 24));
  const hours = Math.floor((newYearDate - currentDate) / (1000 * 60 * 60));
  const minutes = Math.floor((newYearDate - currentDate) / (1000 * 60));
  const seconds = Math.floor((newYearDate - currentDate) / 1000);
  console.log(days, hours, minutes,seconds);
}

countDates();

In this code I have substracted the initialized(NewYearDate) date with the current date and tried to get days, hours, minutes out of it, I got the logic on the internet but can't understand why it is divided by 1000 for all the variables (days, hours, minutes).

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

0

Because when Date is converted to a number the value is in milliseconds
1 second === 1000 milliseconds

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