Reputation: 207
How can an html field be auto filled with a local date time with the name of the time zone beside it.
HTML field:
<tr>
<td>
<label for="date">Date & Time :</label>
</td>
<td>
<input type="date" name="date">
</td>
</tr>
Upvotes: 1
Views: 1303
Reputation: 14023
Give your input field an ID:
<input type="date" name="date" id="your-id">
and than you can just do
<script>
document.getElementById("your-id").value = Date().toString();
</script>`
Without giving it an ID you would have to do
document.getElementsByName("date")[0].value
but you have to be sure there is only one input with name date
Upvotes: 2
Reputation: 1301
Javascript will help you to fill up the date.
<input type="date" name="date" id="date">
<script type="text/javascript">
document.getElementById("date").value = Date().toString();
</script>
Upvotes: 0