JSFiddle - React, Tailwind, and code Playground

HTML

<div id="date">
   From: <input  type="text" size="6" name="date" id="from" class="tcal">
   To:   <input type="text" size="6" name="date1" id="to" class="tcal">
    <button id="1day"> 1 Day </button>
    <button id="2day"> 2 Day </button>
    <button id="month"> 1 Month</button>
    <button id="3month"> 3 Month</button>
    <button id="year"> 1 year</button>
</div>

JavaScript

$('button').click(function(){
      id = $(this).attr('id');
      $('#to').val((new Date()).getMonth() + "-" + (new Date()).getDate() + "-" + (new Date()).getFullYear());   
    
    if(id == '1day'){
         $('#from').val((new Date()).getMonth() + "-" + ((new Date()).getDate()-1) + "-" + (new Date()).getFullYear());          
    }
     if(id == '2day'){
         $('#from').val((new Date()).getMonth() + "-" + ((new Date()).getDate()-2) + "-" + (new Date()).getFullYear());          
    }
    
    if(id == 'month'){
        $('#from').val(((new Date()).getMonth()-1) + "-" + (new Date()).getDate() + "-" + (new Date()).getFullYear());     
    }
    
    if(id == '3month'){
        $('#from').val(((new Date()).getMonth()-3) + "-" + (new Date()).getDate() + "-" + (new Date()).getFullYear());     
    }
    
    if(id == 'year'){
        $('#from').val((new Date()).getMonth() + "-" + (new Date()).getDate() + "-" + ((new Date()).getFullYear()-1));     
    }
});