Skip to main content
Very Popular
Go to Latest
function differenceInWeeks
import { differenceInWeeks } from "https://deno.land/x/date_fns@v2.14.0/index.js";

Examples

// How many full weeks are between 5 July 2014 and 20 July 2014? var 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. var result = differenceInWeeks( new Date(2020, 5, 1), new Date(2020, 2, 6) ) //=> 8

Parameters

dirtyDateLeft
  • the later date
dirtyDateRight
  • the earlier date