我添加到11日至2016年2月19日開始日期和添加11日後它成爲2016年3月1日,但是,當我運行getMonth()JavaScript函數返回feb而不是行軍JavaScript添加日期,但它顯示舊的日期月
這裏是我的代碼
var stDate = new Date($("#datepicker1").val());
//Fri Feb 19 2016 00:00:00 GMT+0500 (Pakistan Standard Time)
var secondSeasonDays = stDate.setDate(stDate.getDate() + firstSeasonDays);
//firstSeasonDays = 11
var secondSeasonDays = new Date(secondSeasonDays);
// it return Tue Mar 01 2016 00:00:00 GMT+0500 (Pakistan Standard Time)
var secondSeasonDays = secondSeasonDays.getDate();
var secondSeasonMonth = secondSeasonDays.getMonth();
alert("second season start date is " + secondSeasonDays + " and start month is " + secondSeasonMonth);
// it alerts second season start date is 1 and start month is 2
而日期secondSeasonDaysHere變量是星期二2016年3月1日00:00:00 GMT + 0500比爲什麼它返回月份爲2 任何建議將是有益的感謝提前
蒙特hs是基於JavaScript的零。一月是0,二月是1,... – j08691