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

161
Visualizações
Why is Moment giving me the date of today and not formatting my date?

I'm using this filter

Vue.filter("toDate", function (value) {
  if (value) {
    return moment(Date(value)).format("yyyy-MM-DD HH:mm");
    
  }
});

The value content is 1529416634

So the Value should be 2018-06-19 15:57

But when I pass the date

return moment(value).format() //1970-01-18 17:50

And with the Date() function

return moment(Date(value)).format("yyyy-MM-DD HH:mm"); //2021-09-18 11:16

It gives me the date of today.

What Am I doing wrong?

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

0

moment and Date takes the time in the number of milliseconds since the Unix Epoch (Jan 1 1970 12AM UTC).

You are currently passing it as the number of seconds since the Unix Epoch.

You can do

return moment(value * 1000).format() //2018-06-19T14:57:14+01:00

or

return moment.unix(value).format() //2018-06-19T14:57:14+01:00

or

return moment(new Date(value * 1000)).format() //2018-06-19T14:57:14+01:00

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