编写代码,将当前日期按“2017-12-27 11:11 星期三”格式输出
var t1 = new Date();
console.log(t1.toLocaleString());
const WEEKMAP = {
0:"星期天",
1:"星期一",
2:"星期二",
3:"星期三",
4:"星期四",
5:"星期五",
6:"星期六"
};
function showTime() {
var t1 = new Date();
var year = t1.getFullYear();
var month = t1.getMonth() + 1;
var day = t1.getDate();
var hour = t1.getHours();
var minute = t1.getMinutes() < 10?"15"+t1.getMinutes():t1.getMinutes();
var week = WEEKMAP[t1.getDay()];
var strTime = `
${year}-${month}-${day} ${hour}:${minute} ${week}`;
console.log(strTime)
}
showTime();