dayjs 使用

dayjs(xxx).format("YYYY-MM-DD HH:mm:ss SSS"); //格式化

dayjs(xxx).add(1, "day").format("YYYY-MM-DD HH:mm:ss SSS"); //相加

const date1 = dayjs("2019-01-25");
const date2 = dayjs("2018-06-05");
date1.diff(date2); //时间差
date1.diff(date2, "month"); //  单位同下
//秒数转时间格式
dayjs.duration(61, "seconds").format('HH:mm');
1
2
3
4
5
6
7
8
9
10
写法写法简写
daysdayd
weeksweekw
monthsmonthM
yearsyeary
hourshourh
minutesminutem
secondsseconds
millisecondsmillisecondms
上次更新: 2022/7/18 03:29:03
贡献者: wangdapan, wangdapan