Find every 6 hours from now
You are basically calculating the modulo manually by doing 

if (inh &gt;= 24) { inh = inh - 24; }


but JavaScript can do it for you, so the inXh() function could be written like this:

var inXh = function(toAdd) {
    return (h + toAdd * 6) % 24;
}


With that, after having declared

var h = new Date().getHours();


you have (at least) two options, choose the one you feel more elegant.

OPTION 1: using for:

var hours = [];
for (var i = 0; i &lt; 4; i++) hours.push(inXh(i));


OPTION 2 (nicer in my opinion): using Array.map():

var hours = [0, 1, 2, 3].map(inXh);


which all together in one line would be

var hours = [0, 1, 2, 3].map(function(toAdd) { return (h + toAdd * 6) % 24; });