From 319f03abfd846565e398fd5d3385925e547f862f Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Fri, 30 May 2025 14:16:31 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9C=8D=E5=8A=A1=E5=99=A8=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E6=A0=BC=E5=BC=8F=E5=8C=96=E6=8C=87=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E5=8C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/date-utils.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/utils/date-utils.ts b/src/utils/date-utils.ts index 5b5243ca..4646d25c 100644 --- a/src/utils/date-utils.ts +++ b/src/utils/date-utils.ts @@ -46,17 +46,17 @@ export function parseDateToStr( /** * 格式时间 * @param date 可转的Date对象 - * @param offset 时间格式 默认 RFC3339 + * @param offset 时间格式 默认 +0000 * @returns 时间格式字符串 */ export function parseDateUTCToStr( date: string | number | Date, offset: string = '+0000' ): string { - // 将时间戳转换为 UTC 时间 - const utcTime = dayjs.utc(date); - // 使用自定义时区偏移格式化时间 - return utcTime.format(`YYYY-MM-DD HH:mm:ss [UTC${offset}]`); + return dayjs + .utc(date) // 将时间戳按 UTC 时间 + .tz(offset) // 使用时区偏移 + .format(`YYYY-MM-DD HH:mm:ss [UTC${offset}]`); // 格式化时间 } /**