Nodejs Hour Add AddHours(hours)

Here you can find the source of AddHours(hours)

Method Source Code

Date.prototype.AddHours = function (hours) {
   return this.setHours(this.getHours() + hours);
}
Date.prototype.Format = function (fmt) {
   var o = {// w  w w  .  ja va2s . c  o m
      "M+": this.getMonth() + 1,
      "d+": this.getDate(),
      "h+": this.getHours(),
      "m+": this.getMinutes(),
      "s+": this.getSeconds(),
      "q+": Math.floor((this.getMonth() + 3) / 3),
      "S": this.getMilliseconds()
   };
   if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
   for (var k in o)
      if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
   return fmt;
};

Related

  1. addHours(h)
    Date.prototype.addHours = function(h) {
      this.setHours(this.getHours() + h);
    };
    
  2. addHours(hours)
    Date.prototype.addHours = function(hours) {
        this.setHours(this.getHours() + hours);
        return this;
    };
    
  3. addHours(n)
    Date.prototype.addHours = function(n) { this.setHours(this.getHours() + n) }
    
  4. addHours(numberOfHours)
    Date.prototype.addHours = function (numberOfHours) {
      if (typeof numberOfHours !== 'number')
        throw new Error('Hours must be a number');
      this.setTime(this.getTime() + (numberOfHours * 60 * 60 * 1000));
      return this;
    };
    
  5. addHours(numberOfHours)
    Date.prototype.addHours = function (numberOfHours) {
      if (typeof numberOfHours !== 'number')
        throw new Error('Hours must be a number');
      this.setTime(this.getTime() + (numberOfHours * 60 * 60 * 1000));
      return this;
    };
    var str = '    something    else  ';
    var r = str.toTitleCase();