Warm tip: This article is reproduced from serverfault.com, please click

javascript-Moment.js .toDate()返回比预期结果晚一年的时间

(javascript - Moment.js .toDate() returns one year later than expected result)

发布于 2020-11-28 01:14:39

我有个约会。2019-12-13 13:40:00代表2019年12月13日下午1:40。当我用moment.js解析时...

moment(props.data[index].date, 'gggg-MM-DD HH:mm:ss')

_d显示的日期Sun Dec 13 2020 14:30:00 GMT-0800 (Pacific Standard Time)我在GitHub上看到很多解释,那里的人们都遇到了这个问题,但它与时区有关,但是,全年差异并不是时区问题。我该怎么做才能解决此问题?

Questioner
SwimMaster
Viewed
11
Rajat Vijay 2020-11-28 09:25:04

gggg第二个参数中的参数用于以ISO周日期格式进行解析尝试做moment(props.data[index].date, 'YYYY-MM-DD HH:mm:ss')