Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

172
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!