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
2
3
4
5
6
7
8
9
10
| 写法 | 写法 | 简写 |
|---|---|---|
| days | day | d |
| weeks | week | w |
| months | month | M |
| years | year | y |
| hours | hour | h |
| minutes | minute | m |
| seconds | second | s |
| milliseconds | millisecond | ms |