是否之间
这指示 Day.js 对象是否位于其他两个提供的日期时间之间。
¥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, '[)')