ChatGPT-Next-Web/app/utils/custom.ts
2023-12-16 23:05:14 +08:00

17 lines
429 B
TypeScript

export function getCurrentTime(): string {
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);
}