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

170
Visualizações
how to find difference between two different formatted dates in year

My backend is sending me the date-time stamp of a document and I want to calculate the age of that document in frontend I am using moment but don't know how to calculate the difference between them

var TodaysDate = new Date();  //Mon May 09 2022 22:52:42 GMT+0530 (India Standard Time)
var DateFromServer = Entity;  // 2021-05-02T13:18:00.000Z

i want Answer in years like 3.4 years

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

With moment you can do it like this

const TodaysDate = moment('Mon May 09 2022 22:52:42 GMT+0530');
const DateFromServer = moment('2021-05-02T13:18:00.000Z');

const diff = TodaysDate.diff(DateFromServer, 'year', true);

console.log(diff.toFixed(2) + " Years");
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