I'm trying to fill an input field with type="date"
with the date of the day the form is being filled.
I tried the following code in PHP:
function getDatetimeNow() {
$tz_object = new DateTimeZone('Brazil/East');
$datetime = new DateTime();
$datetime->setTimezone($tz_object);
return $datetime->format('Y-m-d ');
}
In HTML I did the following:
<input name="name_01" id="id_01" type="date" value="<?php echo getDatetimeNow() ?>" />
You did not print anything, but I also tried JavaScript:
now = new Date;
yr = now.getFullYear();
mt = now.getMonth();
dy = now.getDay();
document.getElementById('id_01').innerHTML= yr+"-"+mt+"-"+dy;
Does anyone have any ideas how to bring the completed field?