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

99
Vistas
Date API is changing date when creating a new instance of Date object with parameter in milliseconds

I'm trying to parse epoch time in milliseconds to UTC timestamp. To achieve this I'm doing:

new Date([my variable in milliseconds]).toUTCString()

and this is returning the following:

output

When the correct date should actually be:

correct date

To recreate this you can use this code:

let dateInMills = 1655154491.8357913;
let parsedDate = new Date(1655154491.8357913).toUTCString();

console.log(parsedDate);

The number that I'm passing to the Date object is the exact same number that is being passed during the tests as it is static data.

More proof on the error:

running the code in the browser console

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

0

The Date constructor can take a number as it's parameter. However, this number should be in milliseconds. In your case, you seams to have the time in second. You should multiply your input by 1000.

let dateInMills = 1655154491.8357913;
let parsedDate = new Date(dateInMills * 1000).toUTCString();

console.log(parsedDate);

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