//添加天Date.prototype.addDays = function (d) { this.setDate(this.getDate() + d);};//添加周Date.prototype.addWeeks = function (w) { this.addDays(w * 7);};//添加月Date.prototype.addMonths = function (m) { var d = this.getDate(); this.setMonth(this.getMonth() + m); if (this.getDate() < d) this.setDate(0);};//添加年Date.prototype.addYears = function (y) { var m = this.getMonth(); this.setFullYear(this.getFullYear() + y); if (m < this.getMonth()) { this.setDate(0); }};