html
html
<span id="date"></span>
js
$(function () {
// 更新日期
$('#date').text(getCurrentDate());
})
function getCurrentDate() {
const today = new Date();
const year = today.getFullYear();
const month = ('0' + (today.getMonth() + 1)).slice(-2); // 月份从0开始,所以加1
const day = ('0' + today.getDate()).slice(-2);
const weekday = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'][today.getDay()];
return `${year}年${month}月${day}日 ${weekday}`;
}