Javascript Date addHours(numberOfHours)

Description

Javascript Date 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;// w  w w.j a  v  a  2  s . c  o  m
};



PreviousNext

Related