1<!-- HTML -->
2<input type="date" class="today">
3
4<script>
5 // JQuery
6 $(document).ready( function() {
7 $('.today').val(getToday());
8 });
9
10 function getToday(){
11 const local = new Date();
12 local.setMinutes(local.getMinutes() - local.getTimezoneOffset());
13 return local.toJSON().slice(0,10);
14 }
15</script>
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>