时间转化 Thu Apr 29 2021 16:23:29 GMT+0800

const demand=Thu Apr 29 2021 16:23:29 GMT+0800;
//const demand = this.ruleForm.date2
const resDate = demand.getFullYear() + '-' + this.transTime((demand.getMonth() + 1)) + '-' + this.transTime(demand.getDate()) + ' '
const resTime = this.transTime(demand.getHours()) + ':' + this.transTime(demand.getMinutes()) + ':' + this.transTime(demand.getSeconds())
console.log(resDate+resTime)// 2021-04-29 16:23:29

transTime(s) {
return s < 10 ? '0' + s : s
},
posted @ 2021-04-22 16:26  lyprecords  阅读(1367)  评论(0)    收藏  举报