datetime-local value doesn't appear on input t

2019-07-14 04:23发布

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条回答
不美不萌又怎样
2楼-- · 2019-07-14 04:46

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]) ?>" />
查看更多
登录 后发表回答