Is Between
This indicates whether the Day.js object is between two other supplied date-time.
This requires the
IsBetween
plugin to work
dayjs.extend(isBetween)
dayjs('2010-10-20').isBetween('2010-10-19', dayjs('2010-10-25'))
// default milliseconds
If you want to limit the granularity to a unit other than milliseconds, pass it as the third parameter. In that case the comparision respects the given unit and the units above.
dayjs().isBetween('2010-10-19', '2010-10-25', 'month') // compares month and year
Units are case insensitive, and support plural and short forms.
The fourth parameter is about inclusivity. A [
indicates inclusion of a value. A (
indicates exclusion.
If the inclusivity parameter is used, both indicators must be passed.
dayjs('2016-10-30').isBetween('2016-01-01', '2016-10-30', null, '[)')