Answers for "html5 get current date in input field"

1

html input date default today

<!-- HTML -->
<input type="date" class="today">

<script>
  // JQuery
  $(document).ready( function() {
    $('.today').val(getToday());
  });
  
  function getToday(){
	const local = new Date();
    local.setMinutes(local.getMinutes() - local.getTimezoneOffset());
	return local.toJSON().slice(0,10);
  }
</script>
Posted by: Guest on September-03-2021
-1

html date input get value

document.getElementById("myDate").value = "2021-02-09";
Posted by: Guest on August-04-2021

Browse Popular Code Answers by Language