在JavaScript中生成每月信用费用的日历
我有小额信贷计算器,我需要在日历(表格)中添加每月费用日期 例如,我在2016年11月10日和12日支付了第一笔费用。表应如下所示:在JavaScript中生成每月信用费用的日历,javascript,jquery,date,credits,Javascript,Jquery,Date,Credits,我有小额信贷计算器,我需要在日历(表格)中添加每月费用日期 例如,我在2016年11月10日和12日支付了第一笔费用。表应如下所示: #日期|费用 1 | 10.11.2016 | 500$ 2 | 10.12.2016 | 500$ 3 | 10.01.2017 | 500$ 4 | 10.02.2017 | 500$ ... 12 | 10.10.2017 | 11$ 如何做到这一点 Date.isLeapYear = function (year) { return (((year
#日期|费用
1 | 10.11.2016 | 500$
2 | 10.12.2016 | 500$
3 | 10.01.2017 | 500$
4 | 10.02.2017 | 500$
...
12 | 10.10.2017 | 11$
如何做到这一点
Date.isLeapYear = function (year) {
return (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0));
};
Date.getDaysInMonth = function (year, month) {
return [31, (Date.isLeapYear(year) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month];
};
Date.prototype.isLeapYear = function () {
return Date.isLeapYear(this.getFullYear());
};
Date.prototype.getDaysInMonth = function () {
return Date.getDaysInMonth(this.getFullYear(), this.getMonth());
};
Date.prototype.addMonths = function (value) {
var n = this.getDate();
this.setDate(1);
this.setMonth(this.getMonth() + value);
this.setDate(Math.min(n, this.getDaysInMonth()));
return this;
};