1<!-- HTML -->
2<input type="date" id="theDate">
3
4<script>
5 // JQuery
6 $(document).ready( function() {
7 $('#theDate').val(new Date().toDateInputValue());
8 });
9
10 // Pure JS
11 document.getElementById('theDate').value = new Date().toDateInputValue();
12
13
14 // Timezone support
15 Date.prototype.toDateInputValue = (function() {
16 var local = new Date(this);
17 local.setMinutes(this.getMinutes() - this.getTimezoneOffset());
18 return local.toJSON().slice(0,10);
19 });
20</script>
1<input type=date id=e>
2<script>
3document.getElementById('e').value = new Date().toISOString().substring(0, 10);
4</script>
5