Day.js 中文文档

当前版本 v1.11

更多文档

数组

你可以使用反映传递给 new Date() 的参数的数字数组创建 Dayjs 对象。

需要配合 ArraySupport 插件才能工作

dayjs.extend(arraySupport)
dayjs([2010, 1, 14, 15, 25, 50, 125]); // February 14th, 3:25:50.125 PM
dayjs.utc([2010, 1, 14, 15, 25, 50, 125]);
dayjs([2010]);        // January 1st
dayjs([2010, 6]);     // July 1st
dayjs([2010, 6, 10]); // July 10th

dayjs({}) 返回当前时间。

请注意,与 new Date(year, month, date) 一样,月份的索引为 0。

Day.js 中文文档 - 粤ICP备14034220号-1