現在時間
不帶任何參數調用 dayjs()
會返回一個表示目前日期和時間的 Day.js 物件。
js
const now = dayjs();
這等同於調用 dayjs(new Date())
。
Day.js 會將 dayjs(undefined)
視為 dayjs()
,因為當未傳入參數時,函數參數的預設值為 undefined
。
Day.js 會將 dayjs(null)
視為無效輸入。
不帶任何參數調用 dayjs()
會返回一個表示目前日期和時間的 Day.js 物件。
const now = dayjs();
這等同於調用 dayjs(new Date())
。
Day.js 會將 dayjs(undefined)
視為 dayjs()
,因為當未傳入參數時,函數參數的預設值為 undefined
。
Day.js 會將 dayjs(null)
視為無效輸入。