Skip to content

getHour

The getHour() function returns the hour (0–23) of a TheDate, adjusted by an optional timezone.

Interactive example

Syntax

typescript
function getHour<
	GenericInput extends TheDate | SerializedTheDate
>(
	input: GenericInput,
	timezone: Timezone = "UTC"
): number

Parameters

  • input: TheDate or SerializedTheDate.
  • timezone: IANA timezone. Default: "UTC".

Return value

An integer between 0 and 23.

See also

Sources

Released under the MIT license.