Reputation: 311
I'm having a problem on how will I convert the datetime
format from my db
to html
datetime-local
. Here's the data format in my database:
2020-07-18T17:25:00Z
When I'm trying to pass this data to html input with a type of datetime-local
it is giving me a warning like this:
Here's my html code with the formatted value:
<input type="datetime-local" required="" value="{{order.pick_up_datetime|date:'Y-m-dTh:i a'}}">
Upvotes: 2
Views: 2221
Reputation: 311
After a day of debugging, I got the answer in my question here. I just did something like this:
<input type="datetime-local" required="" value="{{order.pick_up_datetime|date:'Y-m-d'}}T{{order.pick_up_datetime|time:'H:i:s'}}">
Just separate the value of date
and time
in the value and added a T
(The T
is just a standard (ISO 8601)
way to delimit the time).
The answer here help me to realize and solve my problem: Why does DateTime add a T separator to the timestamp?
Upvotes: 6