del: 格式时间-到指定时区
This commit is contained in:
@@ -21,7 +21,7 @@ const { proConfig, waterMarkContent } = useLayoutStore();
|
||||
import useI18n from '@/hooks/useI18n';
|
||||
import { getServerTime } from '@/api';
|
||||
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||
import { parseDateToStrByUTCOffset } from '@/utils/date-utils';
|
||||
import { parseDateToStr } from '@/utils/date-utils';
|
||||
import { parseUrlPath } from '@/plugins/file-static-url';
|
||||
const { t, currentLocale } = useI18n();
|
||||
const routerStore = useRouterStore();
|
||||
@@ -187,10 +187,7 @@ function fnGetServerTime() {
|
||||
// serverTimeStr.value = parseDateToStr(serverTime.timestamp);
|
||||
// 用DOM直接修改
|
||||
if (serverTimeDom) {
|
||||
serverTimeDom.innerText = parseDateToStrByUTCOffset(
|
||||
serverTime.timestamp,
|
||||
utcOffset
|
||||
);
|
||||
serverTimeDom.innerText = parseDateToStr(serverTime.timestamp);
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
// 依赖来源 https://github.com/iamkun/dayjs
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc'; // 导入 UTC 插件
|
||||
// 应用 UTC 插件
|
||||
dayjs.extend(utc);
|
||||
|
||||
// 导入本地化语言并设为默认使用,只需要全局有引入就行
|
||||
// import('dayjs/locale/zh-cn');
|
||||
@@ -76,21 +73,6 @@ export function diffValue(
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式时间-到指定时区
|
||||
* @param date 可转的Date对象
|
||||
* @param utcOffset 分钟偏移量
|
||||
* @param formatStr 时间格式 默认YYYY-MM-DD HH:mm:ss
|
||||
* @returns 时间格式字符串
|
||||
*/
|
||||
export function parseDateToStrByUTCOffset(
|
||||
date: string | number | Date,
|
||||
utcOffset: number,
|
||||
formatStr: string = YYYY_MM_DD_HH_MM_SS
|
||||
): string {
|
||||
return dayjs(date).utcOffset(utcOffset).format(formatStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化秒值为 ?h?m?s
|
||||
* @param seconds 2558 秒
|
||||
|
||||
Reference in New Issue
Block a user