Nodejs Hour Add addHours(h)

Here you can find the source of addHours(h)

Method Source Code

Date.prototype.addHours = function (h) {
    this.setHours(this.getHours() + h);// w w w . ja  va  2 s  . c o  m
    return this;
}
Date.prototype.addDays = function (d) {
    var month, year, day;
    month = this.getMonth();
    year = this.getFullYear();
    day = this.getDate();
    day = day + d;
    if (day < 1) {
        if (this.getMonth() === 0) {
            month = 11;
            year--;
        }
        else {
            month--;
        }
        if (DateTime.isLeapYear(year)) {
            day = DateTime.monthDaysLeapYear[month] + day;
        }
        else {
            day = DateTime.monthDays[month] + day;
        }
    }
    if (day > DateTime.monthDays[this.getMonth()]) {
        month++;
        day = day - DateTime.monthDays[this.getMonth()];
        if (month > 11) {
            month = 0;
            year++;
        }
    }
    return new Date(year, month, day, 0, 0, 0, 0);
}

Related

  1. addHour()
    Date.prototype.addHour = function(){
      this.setTime(this.getTime() + (60 * 60 * 1000));
    };
    
  2. addHours(h)
    Date.prototype.addHours= function(h){
        this.setHours(this.getHours()+h);
        return this;
    
  3. addHours(h)
    Date.prototype.addHours = function(h) {
        this.setHours(this.getHours() + h);
        return this;
    Date.prototype.addSeconds = function(s) {
      this.setSeconds(this.getSeconds() + s);
      return this;
    
  4. addHours(h)
    Date.prototype.addHours = function(h) {    
       this.setTime(this.getTime() + (h*60*60*1000)); 
       return this;   
    
  5. addHours(h)
    Date.prototype.addHours= function(h){
        this.setHours(this.getHours()+h);
        return this;
    var d = new Date();
    console.log(d.addHours(24));
    
  6. addHours(h)
    Date.prototype.addHours = function (h) {
      this.setHours(this.getHours()+h);
      return this;
    };
    
  7. addHours(h)
    Date.prototype.addHours= function(h){
      this.setHours(this.getHours()+h);
      return this;
    Date.prototype.removeHours= function(h){
      this.setHours(this.getHours()-h);
      return this;
    Date.prototype.addMinutes = function (m) {
    ...
    
  8. addHours(h)
    Date.prototype.addHours = function(h) {
      this.setHours(this.getHours() + h);
    };
    
  9. addHours(hours)
    Date.prototype.addHours = function(hours) {
        this.setHours(this.getHours() + hours);
        return this;
    };