Skip to content

getYear

The getYear() function returns the year corresponding to a TheDate. An IANA timezone can be provided to adjust the result.

Interactive example

Syntax

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

Parameters

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

Return value

The year (integer) corresponding to the date in the requested timezone.

See also

Sources

Released under the MIT license.