const now = new Date();

const year = now.getFullYear();
const month = now.getMonth() + 1; // 注意:月份是从0开始的,所以要加1
const date = now.getDate();
const days = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
const dayOfWeek = days[now.getDay()];

console.log(`今天是 ${year} 年 ${month} 月 ${date} 日, ${dayOfWeek}`);

By lxcss

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注