JSFiddle - React, Tailwind, and code Playground
HTML
<form action="#" method="post" class="" id="form">
<input type="text" id="todaysDate" name="todaysDate" value="" />
<input type="button" id="setDate" value="Today"></input>
</form>
JavaScript
function setDate() {
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) ;
$('#todaysDate').val(today);
}
$('#setDate').click(function(){
setDate();
});