Add dashboard
This commit is contained in:
@@ -20,3 +20,49 @@ export const getDate = (zuluTime: string) => {
|
||||
const time = convertZulu2Beijing(zuluTime);
|
||||
return time.split(" ")[0];
|
||||
};
|
||||
|
||||
export function getTimeBefore(days: number): string {
|
||||
// 获取当前时间
|
||||
const currentDate = new Date();
|
||||
|
||||
// 减去指定的天数
|
||||
currentDate.setUTCDate(currentDate.getUTCDate() - days);
|
||||
|
||||
// 格式化日期为 yyyy-mm-dd
|
||||
const year = currentDate.getUTCFullYear();
|
||||
const month = String(currentDate.getUTCMonth() + 1).padStart(2, "0"); // 月份从 0 开始
|
||||
const day = String(currentDate.getUTCDate()).padStart(2, "0");
|
||||
|
||||
// 格式化时间为 hh:ii:ss
|
||||
const hours = String(currentDate.getUTCHours()).padStart(2, "0");
|
||||
const minutes = String(currentDate.getUTCMinutes()).padStart(2, "0");
|
||||
const seconds = String(currentDate.getUTCSeconds()).padStart(2, "0");
|
||||
|
||||
// 组合成 yyyy-mm-dd hh:ii:ss 格式
|
||||
const formattedDate = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
||||
|
||||
return formattedDate;
|
||||
}
|
||||
|
||||
export function getTimeAfter(days: number): string {
|
||||
// 获取当前时间
|
||||
const currentDate = new Date();
|
||||
|
||||
// 加上指定的天数
|
||||
currentDate.setUTCDate(currentDate.getUTCDate() + days);
|
||||
|
||||
// 格式化日期为 yyyy-mm-dd
|
||||
const year = currentDate.getUTCFullYear();
|
||||
const month = String(currentDate.getUTCMonth() + 1).padStart(2, "0"); // 月份从 0 开始
|
||||
const day = String(currentDate.getUTCDate()).padStart(2, "0");
|
||||
|
||||
// 格式化时间为 hh:ii:ss
|
||||
const hours = String(currentDate.getUTCHours()).padStart(2, "0");
|
||||
const minutes = String(currentDate.getUTCMinutes()).padStart(2, "0");
|
||||
const seconds = String(currentDate.getUTCSeconds()).padStart(2, "0");
|
||||
|
||||
// 组合成 yyyy-mm-dd hh:ii:ss 格式
|
||||
const formattedDate = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
||||
|
||||
return formattedDate;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user