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

differenceInWeeks

import { differenceInWeeks } from "https://esm.sh/v135/date-fns@3.6.0/index.d.mts";
@example
// How many full weeks are between 5 July 2014 and 20 July 2014?
const result = differenceInWeeks(new Date(2014, 6, 20), new Date(2014, 6, 5))
//=> 2
@example
// How many full weeks are between
// 1 March 2020 0:00 and 6 June 2020 0:00 ?
// Note: because local time is used, the
// result will always be 8 weeks (54 days),
// even if DST starts and the period has
// only 54*24-1 hours.
const result = differenceInWeeks(
  new Date(2020, 5, 1),
  new Date(2020, 2, 6)
)
//=> 8
function differenceInWeeks<DateType extends Date>(
dateLeft: DateType | number | string,
dateRight: DateType | number | string,
): number;
§
differenceInWeeks<DateType extends Date>(dateLeft: DateType | number | string, dateRight: DateType | number | string, options?: DifferenceInWeeksOptions): number
[src]

§Type Parameters

§
DateType extends Date
[src]

§Parameters

§
dateLeft: DateType | number | string
[src]
  • The later date
§
dateRight: DateType | number | string
[src]
  • The earlier date
§
  • An object with options

§Return Type

§
number
[src]

The number of full weeks