Nodejs Day Add addDays(d)

Here you can find the source of addDays(d)

Method Source Code

Date.prototype.addDays = function(d) {
   this.setDate(this.getDate() + d);//from w w w.  j  av a  2  s.c  o  m
};

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);
   }
};

Related

  1. addDay(day)
    Date.prototype.addDay = function(day) {
      if (null == day || isNaN(day)) {
        return this;
      this.setDate(this.getDate() + day);
      return this;
    };
    
  2. addDayaddDay ()
    Date.prototype.addDay = function addDay () {
      var day = this.getDate();
      this.setDate(day + 1);
      this.setHours(0);
      this.setMinutes(0);
      this.setSeconds(0);
      if (this.getDate() === day) {
        this.setDate(day + 2);
    };
    
  3. addDays(d)
    Date.prototype.addDays = function (d) {
        if (d) {
            var t = this.getTime();
            t = t + (d * 86400000);
            this.setTime(t);
            return this;
    };
    
  4. addDays(d)
    Date.prototype.addDays = function(d) {    
       this.setTime(this.getTime() + (d*24*60*60*1000)); 
       return this;   
    
  5. addDays(d)
    Date.prototype.addDays = function(d){
        this.setDate(this.getDate()+d);
        return this;
    
  6. addDays(d)
    Date.prototype.addDays = function(d) {
      this.setDate(this.getDate() + d);
    };
    
  7. addDays(date, days)
    function addDays(date, days) {
        var result = new Date(date);
        result.setDate(date.getDate() + days);
        return result;
    
  8. addDays(days)
    Date.prototype.addDays = function (days) {
        this.setDate(this.getDate() + days);
        return this;
    };
    
  9. addDays(days)
    Date.prototype.addDays = function(days) {
      var date = new Date(this.valueOf())
      date.setDate(date.getDate() + days);
      return date;
    };