React-moment常用时间总结

// 今天
[moment(), moment()]
// 昨天
[moment().subtract(1, 'days'),moment().subtract(1, 'days')]
// 本周
[moment().startOf('week'),moment().endOf('week')]
// 本月
[moment().startOf('month'),moment().endOf('month')]
// 上周
moment().week(moment().week() -1).startOf('week'),moment().week(moment().week() -1).endOf('week')]
// 上月
[moment().month(moment().month() -1).startOf('month'),moment().month(moment().month() -1).endOf('month')]
// 上个季度
[moment().quarter(moment().quarter()-1).startOf('quarter'),moment().quarter(moment().quarter() -1).endOf('quarter')]
//前7天,不包含今天
[moment().subtract(7, "days"),moment().subtract(1, "days")]
//近30天,不包含今天
 [moment().subtract(30, "days"),moment().subtract(1, "days")]
// 近三个月
 [moment().subtract(90, "days"),moment().subtract(1, "days")]

//格式化只需使用format
//[moment().format('YYYY-MM-DD 00:00:00'),moment().format('YYYY-MM-DD 23:59:59')]
//当前日期 00:00:00至23:59:59

 

你可能感兴趣的:(React)