datetime-local value doesn't appear on input t

2019-07-14 03:57发布

问题:

I was making a php page where I can edit a given closing date & time. After clicking the edit button, the previous value of datetime-local doesn't appear on the datetime box.

Previous value was 2016-06-17 19:07:00

It only appears like this mm/dd/yyyy --:--:--

This one doesn't display the previous value:

<input type="datetime-local" name="c_datetime" value=<?php echo $row[5] ?> />

But when I do it like this it properly display the date and time.

<?php echo $row[5] ?>

How to make it display the previous value?

Thanks in advance!

回答1:

It looks like you may be missing some quotation marks around the php code:

<input type="datetime-local" name="c_datetime" value="<?= str_replace(" ", "T", $row[5]) ?>" />