Skip to main content

isBefore()

Returns a boolean, false if the first date is after the second date.

Usage

import { isBefore } from 'easy-dates'

isBefore(date, dateToCompare)

Prop types

proptyperequireddefault
datedateyesn/a
dateToComparedateyesn/a

Examples

isBefore(new Date('2022-01-01'), new Date('2022-01-02')) // false
isBefore(new Date('2022-01-01'), new Date('2022-01-01')) // true
isBefore(new Date('2022-01-02'), new Date('2022-01-01')) // true
const today = new Date();
const tomorrow = new Date(today.getTime() + 24 * 60 * 60 * 1000);
isBefore(tomorrow.toString(), today) // error when given the wrong type