时间格式转换 Mon Aug 17 2020 16:29:29 GMT+0800 (中国标准时间)
// Mon Aug 17 2020 16:29:29 GMT+0800 (中国标准时间) 转 年月日时分秒
function timeD(time) {
let d = new Date(time),
data = {
'year': d.getFullYear(),
'month': this.timeP(d.getMonth() + 1),
'day': this.timeP(d.getDate()),
'hour': this.timeP(d.getHours()),
'min': this.timeP(d.getMinutes()),
'sec': this.timeP(d.getSeconds()),
}
return data;
},
// 补0
function timeP(s) {
return s < 10 ? '0' + s : s
},
============
// 年月日时分秒 转 Mon Aug 17 2020 16:29:29 GMT+0800 (中国标准时间)
function timeG(time) {
let t = Date.parse(time);
if (!isNaN(t)) {
return new Date(Date.parse(timeState.replace(/-/g, '/')))
}
}
=========
new Date(Date.parse('2020-08-17 15:24:40'))