js date set date with variable month code example
Example 1: js set datetime
new Date(1776, 6, 4, 12, 30, 0, 0);
new Date(-6106015800000);
new Date("January 31 1980 12:30");
Example 2: get date and change format and increase date or month in javascript jquery
month = Number($("#con_months_of_contract").val());
var date = $('#datepicker2').val();
var newdate = date.split("-").reverse().join("-");
var myDate = new Date(newdate);
var newDate2 = new Date(myDate.setMonth(myDate.getMonth()+month));
newDate2.setDate(newDate2.getDate()-1);
$("#datepicker4").datepicker("setDate", newDate2);