0
function dateColumn() {
var startDate = new Date($("#anStartDate").val()); //the start date
var pmtPeriods = $("#anPaymentPeriods").val(); //number of months in this case
var dateData = new Array(pmtPeriods);
var i = 0;
while (i < pmtPeriods) {
startDate = startDate.add(i).month();
dateData[i] = startDate;
i++
}
alert(dateData);
}
假設我的開始日期是2014-01-01
,並且我將2個月作爲pmtPeriods
。用[2014-02-01, 2014-02-01]
填充我的數組。如果我將pmtPeriods
作爲3,並且開始日期相同,則結果爲[2014-03-01, 2014-03-01, 2014-03-01]
。這是錯誤的。使用循環填充數組,使用月份
隨着pmtPeriods 2,我想結果是:
[2014-02-01, 2014-03-01]
代替
[2014-02-01, 2014-02-01]
什麼是你的問題? – forgivenson
「與pmtPeriods 2我想結果:[2014-02-01,2014-03-01]」? – MrProgram