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
>(
	input: GenericInput,
	timezone?: Timezone
): number

Parameters

  • input: Immutable TheDate.
  • timezone: (Optional) IANA timezone (see date/types/timezone).

Return value

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

See also

Sources

Released under the MIT license.