且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Moment.js返回错误的日期

更新时间:2023-01-31 14:49:26

如果您想在utc中使用时间,请使用:

If you want the time in utc, use:

moment.utc('2013-10-29T00:00:00.000')

正如@MattJohnson指出的,使用时刻构造函数将会将其转换为本地时间。相反(如果您不想使用 utc 方法),则可以将 Z 替换为 +0 。查看字符串日期/时间的选项 http://momentjs.com/docs/#/parsing / string-format /

As @MattJohnson pointed out, using the moment constructor will translate it to local time. Instead (if you don't want to use the utc method), you can replace the Z with +0. See options for string date/time http://momentjs.com/docs/#/parsing/string-format/