Nodejs Month Add addMonths(value)

Here you can find the source of addMonths(value)

Method Source Code

Date.prototype.addMonths = function (value)
{
    var n = this.getDate();
    this.setDate(1);//from w ww.  j ava2 s. c o m
    this.setMonth(this.getMonth() + value);
    this.setDate(Math.min(n, this.getDaysInMonth()));
    return this;
};

Related

  1. addMonths(m)
    Date.prototype.addMonths = function(m) {
      var d = this.getDate();
      this.setMonth(this.getMonth() + m);
      if (this.getDate() < d)
        this.setDate(0);
    };
    
  2. addMonths(months)
    Date.prototype.addMonths = function(months){
      return new Date(this.getTime() + months*this.getDaysInMonthOfYear()*24*60*60*1000);
    
  3. addMonths(months)
    Date.prototype.addMonths = function(months) {
      var n = this.getDate();
      this.setDate(1);
      this.setMonth(this.getMonth() + months);
      this.setDate(Math.min(n, this.getDaysInMonth()));
      return this;
    };
    
  4. addMonths(number)
    Date.prototype.addMonths = function (number) {
        var date = new Date(this);
        date.setMonth(date.getMonth() + number);
        return date;
    };
    
  5. addMonths(value)
    Date.prototype.addMonths = function(value) {
      var date = this.getDate();
      this.setMonth(this.getMonth() + value);
      if (this.getDate() < date) {
        this.setDate(0);
      return this;
    };