Skip to content

getMonth ​

The getMonth() function returns the month (1–12) corresponding to a TheDate, with optional support for an IANA timezone.

Interactive example ​

Syntax ​

typescript
function getMonth<
	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 12 (January = 1).

See also ​

Sources ​

Released under the MIT license.