天博·体育「中国」官方网站/登录入口-IOS/安卓通用版/手机APP下载
«

moment常用日期快速选择时间范围

时间:2022-6-17 10:54     作者:一行虎     分类: 其他


'1分钟之前': [moment().subtract(1, 'm'), moment().subtract(1, 'm')],
'3分钟之前': [moment().subtract(3, 'm'), moment()],
'15分钟之前': [moment().subtract(15, 'm'), moment()],
'1小时之前': [moment().subtract(1, 'h'), moment()],
'1天': [moment().startOf('day'), moment().endOf('day')],
'今天': [moment(), moment()],
'最近3天': [moment().subtract(3, 'days'), moment()],
'本周': [moment().startOf('week'), moment().endOf('week')],
'最近7天': [moment().subtract(6, 'days'), moment()],
'本月': [moment().startOf('month'), moment().endOf('month')],
'最近30天': [moment().subtract(29, 'days'), moment()],
'最近3个月': [moment().subtract(3, 'month'), moment()],
'最近半年': [moment().subtract(6, 'month'), 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