2
I’m trying to fill in an input field with type="date"
with the date of the day the form is being completed.
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() ?>" />
Did not print anything, but I also tried by 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 idea how to bring the field filled?