方法
const time = dayjs()
// d {$L: "en", $d: Thu Jul 08 2021 10:59:37 GMT+0800 (中国标准时间), $x: {…}, $y: 2021, $M: 6, …}
const time = dayjs().format()
//2021-07-08T11:00:24+08:00
const time = dayjs('2018-04-04T16:00:00.000Z')
//d {$L: "en", $d: Thu Apr 05 2018 00:00:00 GMT+0800 (中国标准时间), $x: {…}, $y: 2018, $M: 3, …}
const time = dayjs("12-25-1995").format() // 1995-12-25T00:00:00+08:00
const time = dayjs(1318781876406).format() //2011-10-17T00:17:56+08:00
const time = new Date(2018, 8, 18)
// 设置今天 小时/分钟/秒/毫秒(当超出时间,会往前进一) 2021-07-08T05:40:01+08:00
const time = dayjs().hour(5).minute(39).second(61).millisecond(40).format()
// 获取当前时间 年(year)月(month)日(date) 小时(hour)分钟(minute)秒(second)毫秒(millisecond)
const time = dayjs().get('millisecond')
// ***方法*** 年(year)月(month)日(day) 小时(hour)分钟(minute)秒(second)毫秒(millisecond)
// add 加
const time = dayjs().add(7, 'year')
// subtract 减
const time = dayjs().subtract(7, 'year')
// 开始时间 startOf 结束 endOf
const time = dayjs().startOf('year').format()
const time = dayjs().endOf('year').format()
const time = dayjs().format()
// 格式化日期
const time = dayjs().format('DD/MM/YYYY') 03/4/2019
// 比对两个日期的差值 , 可以设置第二个参数看差几个月或者多少天
const date1 = dayjs('2019-01-25')
const date2 = dayjs('2018-06-05')
const as = date1.diff(date2,'month') // 20214000000 default milliseconds
const time = dayjs().valueOf() // 获取毫秒的时间戳 1625738221175
const time = dayjs().unix() //获取秒的时间戳 1625738259
const time = dayjs().daysInMonth() //获取当前月份的天数
const time = dayjs().toDate() //获取中国标准时间 Thu Jul 08 2021 18:01:05 GMT+0800 (中国标准时间)
// 返回日期的字符串表示形式。
const time = dayjs().toString() //Fri, 09 Jul 2021 07:00:36 GM
// 查询当前时间是否在这个时间之前,返回bool。 可接收第二个参数
const time = dayjs().isBefore(1595519999999,'year')
// 查询当前时间是否在这个时间之后,返回bool。 可接收第二个参数
const time = dayjs().isAfter(1595519999999,'year')
// 是否为Day.js对象。
const time = dayjs.isDayjs(dayjs()) // true