Merge branch 'lichang' into lite
This commit is contained in:
@@ -46,17 +46,17 @@ export function parseDateToStr(
|
|||||||
/**
|
/**
|
||||||
* 格式时间
|
* 格式时间
|
||||||
* @param date 可转的Date对象
|
* @param date 可转的Date对象
|
||||||
* @param offset 时间格式 默认 RFC3339
|
* @param offset 时间格式 默认 +0000
|
||||||
* @returns 时间格式字符串
|
* @returns 时间格式字符串
|
||||||
*/
|
*/
|
||||||
export function parseDateUTCToStr(
|
export function parseDateUTCToStr(
|
||||||
date: string | number | Date,
|
date: string | number | Date,
|
||||||
offset: string = '+0000'
|
offset: string = '+0000'
|
||||||
): string {
|
): string {
|
||||||
// 将时间戳转换为 UTC 时间
|
return dayjs
|
||||||
const utcTime = dayjs.utc(date);
|
.utc(date) // 将时间戳按 UTC 时间
|
||||||
// 使用自定义时区偏移格式化时间
|
.tz(offset) // 使用时区偏移
|
||||||
return utcTime.format(`YYYY-MM-DD HH:mm:ss [UTC${offset}]`);
|
.format(`YYYY-MM-DD HH:mm:ss [UTC${offset}]`); // 格式化时间
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user