Author: Admin 05/15/2022
Language:
PHP
Tags: input datetime-local php html
Here's some code to set the default datetime for an input box with its type set to datetime-local using HTML and PHP.
Set the datetime format in PHP.
<?php
$datetime = date('Y-m-d\TH:i')
?>
Form field input box code.
<input type="datetime-local" value="<?php echo $datetime; ?>"/>
Or use the PHP short echo tag.
<input type="datetime-local" value="<?=$datetime; ?>"/>