W3cubDocs

/date-fns

isBefore

Is the first date before the second one?

Description

Is the first date before the second one?

Usage

// CommonJS
var isBefore = require('date-fns/isBefore')
// ES 2015
import isBefore from 'date-fns/isBefore'
// ESM
import { isBefore } from 'date-fns'

Syntax

isBefore(date, dateToCompare)

Arguments

Name Description
date

the date that should be before the other one to return true

dateToCompare

the date to compare with

Returns

Description

the first date is before the second date

Exceptions

Type Description
TypeError

2 arguments required

Examples

// Is 10 July 1989 before 11 February 1987?
const result = isBefore(new Date(1989, 6, 10), new Date(1987, 1, 11))
//=> false

© 2021 Sasha Koss and Lesha Koss
Licensed under the MIT License.
https://date-fns.org/v2.29.2/docs/isBefore