0

我正在使用Quasar框架,我试图弄清楚如何以格式化的 GMT 日期显示日期,而不是使用我的计算机所在的本地时区计算的日期。

我专门使用 Quasar Date Utils

import { date } from 'quasar'

export function ciiFormatDate (dt, format = 'MMM DD, YYYY') {
  console.log('---------------')
  console.log('dt = ', dt)
  console.log('formatted dt = ', date.formatDate(dt, format))
  console.log('---------------')
  console.log('newdt = ', new Date(dt))
  console.log('formatted newdt = ', date.formatDate(new Date(dt), format))
  console.log('---------------')
  console.log('new date = ', new Date(dt).toUTCString())
  console.log('formatted new date = ', date.formatDate(new Date(dt).toUTCString(), format))
}

产生:

---------------
dt =  2018-09-14T02:33:00.000Z
formatted dt =  Sep 13, 2018
---------------
newdt =  Thu Sep 13 2018 19:33:00 GMT-0700 (Pacific Daylight Time)
formatted newdt =  Sep 13, 2018
---------------
new date =  Fri, 14 Sep 2018 02:33:00 GMT
formatted new date =  Sep 13, 2018 <-- TRYING TO GE THIS TO SHOW Sep 14th
4

0 回答 0