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}`);