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

isWithinInterval

import { isWithinInterval } from "https://esm.sh/v135/date-fns@3.6.0/index.d.mts";
@example
// For the date within the interval:
isWithinInterval(new Date(2014, 0, 3), {
  start: new Date(2014, 0, 1),
  end: new Date(2014, 0, 7)
})
//=> true
@example
// For the date outside of the interval:
isWithinInterval(new Date(2014, 0, 10), {
  start: new Date(2014, 0, 1),
  end: new Date(2014, 0, 7)
})
//=> false
@example
// For date equal to interval start:
isWithinInterval(date, { start, end: date })
// => true
@example
// For date equal to interval end:
isWithinInterval(date, { start: date, end })
// => true
function isWithinInterval<DateType extends Date>(date: DateType | number | string, interval: Interval<DateType>): boolean;
§
isWithinInterval<DateType extends Date>(date: DateType | number | string, interval: Interval<DateType>): boolean
[src]

§Type Parameters

§
DateType extends Date
[src]

§Parameters

§
date: DateType | number | string
[src]
  • The date to check
§
interval: Interval<DateType>
[src]
  • The interval to check

§Return Type

§
boolean
[src]

The date is within the interval