I'm trying to calculate date by selecting number of months to shows result date with -1 day.
$('#txtjQcal15_1, #month_number').change(function(){
var months = +$('#month_number').val();
var endmDate = new Date($('#txtjQcal15_1').val());
if (isNaN(endmDate)) {endmDate = 0;}
else {
endmDate.setMonth(endmDate.getMonth() + Number(months) );
$('#date_result_month').val( endmDate.getFullYear() + '-' + ( "0" + (endmDate.getMonth() + 1)).slice(-2) + '-' + ("0" + (endmDate.getDate() - 1)).slice(-2) ) ;
if i select 2016-09-09 result shows 2016-10-08 and its okay.
Only Calculation for begging of the month is wrong for example if i select 2016-09-01 the result shows:2016-10-00 !!! instead of 2016-09-30