Skip to content

getWeekOfYear

The getWeekOfYear() function calculates the ISO 8601 week number (1–53) for a TheDate, with an optional timezone.

Interactive example

Syntax

typescript
function getWeekOfYear<
	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 1 and 53 corresponding to the ISO week.

See also

Sources

Released under the MIT license.