美文网首页
时间格式转换 Mon Aug 17 2020 16:29:29

时间格式转换 Mon Aug 17 2020 16:29:29

作者: 刘淘 | 来源:发表于2020-08-18 13:37 被阅读0次

时间格式转换 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'))

相关文章

网友评论

      本文标题:时间格式转换 Mon Aug 17 2020 16:29:29

      本文链接:https://www.haomeiwen.com/subject/aoohjktx.html