是否相同
这指示 Day.js 对象是否与其他提供的日期时间相同。
¥This indicates whether the Day.js object is the same as the other supplied date-time.
dayjs().isSame(dayjs('2011-01-01')) // default milliseconds
如果要将粒度限制为毫秒以外的单位,请将其作为第二个参数传递。
¥If you want to limit the granularity to a unit other than milliseconds, pass it as the second parameter.
当包含第二个参数时,它将匹配所有等于或大于的单位。传入 month
将检查 month
和 year
。传入 day
将检查 day
、month
和 year
。
¥When including a second parameter, it will match all units equal or larger. Passing in month
will check month
and year
. Passing in day
will check day
, month
, and year
.
dayjs().isSame('2011-01-01', 'year')
单位不区分大小写,并支持复数和缩写形式。
¥Units are case insensitive, and support plural and short forms.