数组
你可以使用数字数组来创建一个 Dayjs 对象。该数组的参数与 new Date()
构造函数接收的参数相同。
TIP
这需要使用 ArraySupport 插件。
js
dayjs.extend(arraySupport);
dayjs([2010, 1, 14, 15, 25, 50, 125]); // 2010 年 2 月 14 日 15:25:50.125
dayjs.utc([2010, 1, 14, 15, 25, 50, 125]);
dayjs([2010]); // 2010 年 1 月 1 日
dayjs([2010, 6]); // 2010 年 7 月 1 日
dayjs([2010, 6, 10]); // 2010 年 7 月 10 日
dayjs([])
返回当前时间。
请注意,与 new Date(year, month, date)
相同,月份的索引从 0 开始(0 代表 1 月,1 代表 2 月,以此类推)。