setHours
Commons
stable
Return a new Date with the hours field replaced by the given count. The original date is never mutated.
API
Signature
Full TypeScript signature sourced from the util file.
API
Parameters
Input parameters accepted by this util.
- daterequiredDate
- The source date. It is cloned before the hours field is updated.
- countrequirednumber
- The hours value to set (0–23).
API
Return value
The value returned by this util.
- A new Date object with the specified hours field.
Usage
Examples
Ready-to-paste usage snippets.
Set the hour on a date