JSFiddle - React, Tailwind, and code Playground
by Blu Angel
HTML
<script>
function getDateAhead()
{
var str = document.getElementById('fromDate').value;
var res = str.split("-");
var year = parseInt(res[0])+1;
var month = parseInt(res[1])-1;
if (month <= 9 && month > 0 )
{
month = "0"+month;
}
else if (month == 0)
{
month = "12";
year = year - 1;
}
var newdate = year+"-"+month;
console.log(str);
console.log(newdate);
document.getElementById('toDate').value = newdate;
}
</script>
<input type="month" id="fromDate" onChange="getDateAhead()"/>
<input type="month" id="toDate"/>