Thu Mar 07 2019 19:00:00 GMT+0800 (中國標準時間) 轉換爲yyyy-MM-dd HH:mm:ss

  1. Thu Mar 07 2019 19:00:00 GMT+0800 (中國標準時間) 轉換爲 2019-03-07 19:00:00
const d = new Date(Thu Mar 07 2019 19: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())
p(s) {
   return s < 10 ? '0' + s : s
}
  1. 2019-03-07 19:00:00轉換爲 Thu Mar 07 2019 19:00:00 GMT+0800 (中國標準時間)
parserDate(date) {
      var t = Date.parse(date)
      if (!isNaN(t)) {
        return new Date(Date.parse(date.replace(/-/g, '/')))
      }
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章