js时间格式转化
Thu Mar 07 2019 12:00:00 GMT+0800 (中国标准时间) 转化为2020-01-01 00:00:00格式()
const d = new Date(Thu Mar 07 2019 12:00:00 GMT+0800 (中国标准时间))
const resDate = d.getFullYear() + '-' + this.p((d.getMonth() + 1)) + '-' + this.p(d.getDate())
const resTime = this.p(d.getHours()) + ':' + this.p(d.getMinutes()) + ':' + this.p(d.getSeconds())
// 不够10 前面加0
p(s) {
return s < 10 ? '0' + s : s
},
2020-01-01 00:00:00 转化为 Thu Mar 07 2019 12:00:00 GMT+0800 (中国标准时间)
parserDate(date) {
var t = Date.parse(date)
if (!isNaN(t)) {
return new Date(Date.parse(date.replace(/-/g, '/')))
}
},