ChatGPT-Next-Web/app/utils/custom.ts
2024-03-26 00:32:46 +08:00

19 lines
459 B
TypeScript

export function getCurrentTime(now?: Date): string {
if (!now) {
const now = new Date();
}
const formatter = new Intl.DateTimeFormat("zh-CN", {
timeZone: "Asia/Shanghai", // 设置为中国标准时间
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
});
// console.log(formattedDateTime); // 输出中国标准时间格式
return formatter.format(now);
}