mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-14 11:05:06 +08:00
mp:完成公众号统计的用户累计数据、消息概况数据
This commit is contained in:
@ -34,17 +34,14 @@ export function endOfDay(date) {
|
||||
}
|
||||
|
||||
export function betweenDay(date1, date2) {
|
||||
// 适配 string 字符串的日期
|
||||
if (typeof date1 === 'string') {
|
||||
date1 = new Date(date1);
|
||||
}
|
||||
if (typeof date2 === 'string') {
|
||||
date2 = new Date(date2);
|
||||
}
|
||||
date1 = convertDate(date1);
|
||||
date2 = convertDate(date2);
|
||||
// 计算差值
|
||||
return Math.floor((date2.getTime() - date1.getTime()) / (24 * 3600 * 1000));
|
||||
}
|
||||
|
||||
export function formatDate(date, fmt) {
|
||||
date = convertDate(date);
|
||||
const o = {
|
||||
"M+": date.getMonth() + 1, //月份
|
||||
"d+": date.getDate(), //日
|
||||
@ -64,3 +61,15 @@ export function formatDate(date, fmt) {
|
||||
}
|
||||
return fmt;
|
||||
}
|
||||
|
||||
export function addTime(date, time) {
|
||||
date = convertDate(date);
|
||||
return new Date(date.getTime() + time);
|
||||
}
|
||||
|
||||
export function convertDate(date) {
|
||||
if (typeof date === 'string') {
|
||||
return new Date(date);
|
||||
}
|
||||
return date;
|
||||
}
|
||||
|
Reference in New Issue
Block a user