setHours (JavaScript)

Sets the hour in local time. Optionally sets the minute, second, and millisecond.

Defined in

Date (Standard - JavaScript)

Syntax

setHours(hours:int) : long

setHours(hours:int, min:int) : long

setHours(hours:int, min:int, sec:int) : long

setHours(hours:int, min:int, sec:int, ms:int) : long

Parameters Description
hours The hour in local time where the hours in a day are 0 through 23.
min The minute in local time where the minutes in an hour are 0 through 59.
sec The second in local time where the seconds in a minute are 0 through 59.
ms The millisecond in local time where the milliseconds in a second are 0 through 999.
Return value Description
long The new time in numeric format.

Examples

This computed label sets the current time to the next hour.
var date = new Date();
date.setHours(date.getHours() + 1, 0, 0, 0);
date.toString()