Javascript Date addHours(h)

Description

Javascript Date addHours(h)


Date.prototype.addHours = function(h) {
    this.setHours(this.getHours() + h);//from   ww  w. j  a  v a 2s . co m
    return this;
}

Javascript Date addHours(h)

Date.prototype.addHours = function(h) {    
   this.setTime(this.getTime() + (h*60*60*1000)); 
   return this;   
}

Javascript Date addHours(h)

function convertDateToUTC(date) { 
 return new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds()); 
}

Date.prototype.addHours= function(h){
    this.setHours(this.getHours()+h);// ww  w  . ja  v  a 2  s  . com
    return this;
}

Javascript Date addHours(h)


Date.prototype.addHours = function(h) { this.setHours(this.getHours()+h); return this; }
console.log("test date: " + new Date().addHours(-2));



PreviousNext

Related