700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > Tue Jun 28 15:30:29 GMT+0800 (中国标准时间) 日期格式化

Tue Jun 28 15:30:29 GMT+0800 (中国标准时间) 日期格式化

时间:2020-09-23 17:44:38

相关推荐

Tue Jun 28  15:30:29 GMT+0800 (中国标准时间) 日期格式化

1、 Tue Jun 28 15:30:29 GMT+0800 (中国标准时间) 转换为 -06-28 15:30:29

代码如下

const d = new Date(Tue Jun 28 15:30:29 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())

p为不够10添加0的函数

p(s) {return s < 10 ? '0' + s : s},

2、 -06-28 15:30:29转换为 Tue Jun 28 15:30:29 GMT+0800 (中国标准时间)

代码如下

parserDate(date) {var t = Date.parse(date)if (!isNaN(t)) {return new Date(Date.parse(date.replace(/-/g, '/')))}},

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。