const now = new Date(); const year = now.getFullYear(); const month = (now.getMonth() + 1).toString().padStart(2, '0'); const date = now.getDate().toString().padStart(2, '0'); const hours = now.getHours().toString().padStart(2, '0'); const minutes = now.getMinutes().toString().padStart(2, '0'); const seconds = now.getSeconds().toString().padStart(2, '0'); const weekdays = [ "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]; const week = weekdays[now.getDay()]; //星期 const time = `${year}-${month}-${date} ${hours}:${minutes}:${seconds}` //年月日 时分秒