function dateFormat(date,format="YYYY-MM-DD HH:mm:ss"){
let config = {
YYYY:date.getFullYear(),
MM:date.getMonth()+1,
DD:date.getDate(),
HH:date.getHours(),
mm:date.getMinutes(),
ss:date.getSeconds()
}
for(let key in config){
format = format.replace(key,config[key])
}
return format
}
const date = new Date('2020-10-3 18:20:34')
let res = dateFormat(date,"YYYY年MM月DD日 HH:mm:ss")
console.log(res)//2020年10月3日 18:20:34
一个日期处理的类库:http://momentjs.cn/