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

167
Visualizações
Angular converting string to date error invalid

I am getting a date in the form of string date: '2022-07-15T09:29:24.958922Z[GMT]', When I convert it in to date then I get error invalid date. Does someone know how to solve it?

   const myDate = response; // '2022-07-15T09:29:24.958922Z[GMT]'
   this.transactionDate = new Date(myDate);

about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

So the problem is [GMT] in your response string.

Either your response should be something like this

new Date("Fri Jan 20 2022 11:51:36 GMT-0500")

or you need to remove [GMT] from your existing string

 var datestring ='2022-07-15T09:29:24.958922Z[GMT]';
 datestring.substr(0,datestring.indexOf('['));
 new Date(datestring)

var withGMT = new Date("Fri Jan 22 2022 11:51:36 GMT-0500")
console.log(withGMT);

var dateString ='2022-07-15T09:29:24.958922Z[GMT]';
var withoutGMT=dateString.substr(0,dateString.indexOf('['));
console.log(new Date(withoutGMT))

about 4 years ago · Santiago Gelvez 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