dayjs 的用法 plugin isSameOrBefore
孫柏青
1 min read
doc: https://day.js.org/docs/en/query/is-same-or-before
1. 前面要加 import
2. dayjs 要 dayjs.extend(isSameOrBefore)
3. 直接用 tz() 就好,裡面不用加 ('Asia/Taipei') 我沒聽懂原因。
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore'
dayjs.extend(isSameOrBefore)
const todayDate = dayjs().tz()
dayjs(initialDate) .tz() .isSameOrBefore(todayDate)
0
Subscribe to my newsletter
Read articles from 孫柏青 directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by