Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Very Popular
Latest
function default
import { default } from "https://deno.land/x/date_fns@v2.22.1/differenceInWeeks/index.ts";

Examples

// 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

// 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

Parameters

dirtyDateLeft: Date | number
  • the later date
dirtyDateRight: Date | number
  • the earlier date

Returns

number

the number of full weeks