fix: 服务器时间格式化指定时区
This commit is contained in:
@@ -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}]`); // 格式化时间
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user