Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

236
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda