function date() { let weekday = []; weekday[0] = "周日"; weekday[1] = "周一"; weekday[2] = "周二"; weekday[3] = "周三"; weekday[4] = "周四"; weekday[5] = "周五"; weekday[6] = "周六"; let date = new Date(); let year = date.getFullYear(); let month = date.getMonth() + 1; let day = date.getDate(); let hours = date.getHours(); let minute = date.getMinutes(); let second = date.getSeconds(); let week = weekday[date.getDay()]; console.log(`${year}年${month}月${day}日,${week},${hours}时${minute}分${second}秒`); } date();
原文:https://www.cnblogs.com/cj-18/p/9097538.html