增加时间处理函数
This commit is contained in:
parent
601606a6fd
commit
979bc37d8b
|
|
@ -0,0 +1,30 @@
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
|
// 获取今天的开始和结束时间
|
||||||
|
export function getTodayTimestamps() {
|
||||||
|
const start = dayjs().startOf('day').format('YYYY-MM-DD HH:mm:ss');
|
||||||
|
const end = dayjs().endOf('day').format('YYYY-MM-DD HH:mm:ss');
|
||||||
|
return { start, end ,label:'今日'};
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取昨天的开始和结束时间
|
||||||
|
export function getYesterdayTimestamps() {
|
||||||
|
const start = dayjs().subtract(1, 'day').startOf('day').format('YYYY-MM-DD HH:mm:ss');
|
||||||
|
const end = dayjs().subtract(1, 'day').endOf('day').format('YYYY-MM-DD HH:mm:ss');
|
||||||
|
return { start, end ,label:'昨日'};
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取本周的开始和结束时间
|
||||||
|
export function getThisWeekTimestamps() {
|
||||||
|
const start = dayjs().startOf('week').format('YYYY-MM-DD HH:mm:ss');
|
||||||
|
const end = dayjs().endOf('week').format('YYYY-MM-DD HH:mm:ss');
|
||||||
|
return { start, end,label:'本周' };
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取本月的开始和结束时间
|
||||||
|
export function getThisMonthTimestamps() {
|
||||||
|
const start = dayjs().startOf('month').format('YYYY-MM-DD HH:mm:ss');
|
||||||
|
const end = dayjs().endOf('month').format('YYYY-MM-DD HH:mm:ss');
|
||||||
|
return { start, end ,label:'本月'};
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Reference in New Issue