Date.setHours

setHours – Set the hours, according to local time (0–23).

Description

Date.setHours(integer hours)

Parameters

Name Description Type Default Optional
hours integer No

Return values

Integer. The new timestamp.

Examples

Example #1 – setHours example
var date = new Date(2015, 9, 21, 16, 29, 00); console.log(date.getTime()); // 1445437740000 (CEST) // 1445459340000 (EDT) console.log(date.setHours(10)); // 1445416140000 (CEST) // 1445437740000 (EDT) console.log(date); // 21 October 2015 10:29:00

External references