Responding to your question itself "Function to add hours or days to a Date":
You want a function to do this for you, well, it's an easy task, as you can see in @CiganoMorrisonMendez's answer , you may not need a function, however, since you > A function, you can link one in the Prototype of the object itself Date , which would state the following:
Date.prototype.addHoras = function(horas){
this.setHours(this.getHours() + horas)
};
Date.prototype.addMinutos = function(minutos){
this.setMinutes(this.getMinutes() + minutos)
};
Date.prototype.addSegundos = function(segundos){
this.setSeconds(this.getSeconds() + segundos)
};
Date.prototype.addDias = function(dias){
this.setDate(this.getDate() + dias)
};
Date.prototype.addMeses = function(meses){
this.setMonth(this.getMonth() + meses)
};
Date.prototype.addAnos = function(anos){
this.setYear(this.getFullYear() + anos)
};
Note that in addition to what you asked for (hours or days) I also added functionality for hours, minutes, seconds, days, months, and years.
After the prototype's declaration you can use them as follows:
//Criando uma data sem parâmetros (tempo atual)
var dt = new Date();
//Exemplo adicionando 1 hora na sua data
dt.addHora(1);
//Exemplo adicionando 30 minutos na sua data
dt.addMinutos(30);
//Exemplo adicionando 15 segundos na sua data
dt.addSegundos(15);
//Exemplo adicionando 10 dias na sua data
dt.addDias(10);
//Exemplo adicionando 2 meses na sua data:
dt.addMeses(2);
//Exemplo adicionando 1 ano na sua data:
dt.addAnos(1);
//Imprimindo ela no console
console.log(dt);
In this way you can add hours / minutes / seconds / days / months / years to your date easily.