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

240
Vistas
How Do I Convert Timestamp to Number of Days in JavaScript/React

Please I received a response from a REST API, and in the JSON object, the time value was a timestamp. However, I need to render it as a "number of days" kind of format.

I received this particular time stamp: "2022-01-12T13:05:16Z"

I want to render it as something like "5 days ago"

How do I go about this please?

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

0

transform the current date and the date you want to milliseconds with .getTime() then subtract it then split the result to milliseconds in a day and you get the number of days passed, Math.ceil to round the number up

console.log(Math.ceil((new Date().getTime() - new Date("2022-01-12T13:05:16Z").getTime()) / 86400000))

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