首先月份需要+1,所以3月的值为2;
其次获取日是getDate,而不是getDay(获取周几),所以周二的值为2.
const date = new Date()
const year = date.getFullYear()
const month = date.getMonth() + 1
const day = date.getDate()
const hour = date.getHours()
const minute = date.getMinutes()
const second = date.getSeconds()
let now = ([year, month, day]).map(n => n.toString()[1] ? n : `0${n}`).join("/") + " " + ([hour, minute, second]).map(n => n.toString()[1] ? n : `0${n}`).join(":")
console.log(now)