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

173
Visualizações
setting dynamic value in date-time-local in react

I have one get and post APIs which involve date-time-local input. First I sent the date-time values to the server via post API and then get the same values from the get method.

the same date-time value with the same format I received from the server but when I set it as the input date-time-local value, it was not visible.

My input type

<input type="datetime-local" name="year" class="form-control" value={this.state.dateTime} />
//value coming from the server is in the format of 2021-11-11T16:27:00Z

I faced this error in the console

The specified value "2021-11-11T16:27:00Z" does not conform to the required format.  The format is "yyyy-MM-ddThh:mm" followed by optional ":ss" or ":ss.SSS".

I also tried to convert server string values to the date object but it did not work.

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

0

Try passing this.state.dateTime.toLocalString() into your input. This looks like it would generate the format it needs.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString

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