Answers for "how to make current date as nam ein html input box"

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

set date to input date

var now = new Date();
var day = ("0" + now.getDate()).slice(-2);
var month = ("0" + (now.getMonth() + 1)).slice(-2);
var today = now.getFullYear() + "-" + month + "-" + day;
Posted by: Guest on September-26-2021

Code answers related to "how to make current date as nam ein html input box"

Browse Popular Code Answers by Language