Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

getWeek

import { getWeek } from "https://esm.sh/v135/date-fns@3.6.0/index.d.mts";
@example
// Which week of the local week numbering year is 2 January 2005 with default options?
const result = getWeek(new Date(2005, 0, 2))
//=> 2
@example
// Which week of the local week numbering year is 2 January 2005,
// if Monday is the first day of the week,
// and the first week of the year always contains 4 January?
const result = getWeek(new Date(2005, 0, 2), {
  weekStartsOn: 1,
  firstWeekContainsDate: 4
})
//=> 53
function getWeek<DateType extends Date>(date: DateType | number | string, options?: GetWeekOptions): number;
§
getWeek<DateType extends Date>(date: DateType | number | string, options?: GetWeekOptions): number
[src]

§Type Parameters

§
DateType extends Date
[src]

§Parameters

§
date: DateType | number | string
[src]
  • The given date
§
options?: GetWeekOptions optional
[src]
  • An object with options

§Return Type

§
number
[src]

The week