格式化
moment().format('YYYY-MM-DD HH:mm:ss')
moment().format('YYYY-MM-DD HH:mm:ss.SSS')
时间戳
秒级单位
moment().format('X')
moment().unix()
毫秒级单位
moment().format('x')
moment().valueOf()
获取时间
今天00:00:00
moment().startOf('day')
本周第一天(周日)00:00:00
moment().startOf('week')
本周周一00:00:00
moment().startOf('isoWeek')
当前月第一天00:00:00
moment().startOf('month')
当前季度第一天00:00:00
moment().startOf('quarter')
今天23:59:59
moment().endOf('day')
本周最后一天(周六)23:59:59
moment().endOf('week')
本周周日23:59:59
moment().endOf('isoWeek')
当前月最后一天23:59:59
moment().endOf('month')
当前季度最后一天23:59:59
moment().endOf('quarter')
上周一00:00:00~周日23:59:59
const startDate = moment().week(moment().week() - 1).startOf('week').valueOf();
const endDate = moment().week(moment().week() - 1).endOf('week').valueOf();
上个月一号的00:00:00到最后一天的23:59:59
const startDate = moment().month(moment().month() - 1).startOf('month').valueOf();
const endDate = moment().month(moment().month() - 1).endOf('month').valueOf();
上个季度第1个月1号的00:00:00~上个季度最后1个月最后1天的23:59:59
const startDate = moment().month(moment().month() - 1).startOf('month').valueOf();
const endDate = moment().month(moment().month() - 1).endOf('month').valueOf();