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