【发布时间】:2015-03-01 11:17:56
【问题描述】:
我收到Deprecation warning: moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to https://github.com/moment/moment/issues/1407 for more info.
但我是一个新手,我不知道如何解决它,所以上面的消息消失了。
我认为问题在于这两行,但我不确定。
var nextMonth = moment(moment(year + "-" + month + "-1")).add(1, "months").format("MM");
var nextYear = moment(moment(year + "-" + month + "-1")).add(1, "months").format("YYYY");
我已经检查了https://github.com/moment/moment/issues/1407 和Deprecation warning: moment construction falls back to js Date,但似乎都无法解决我的问题。
我想知道在这个计算中我应该在哪里告诉当前的格式,或者至少如何以正确的格式进行这个计算,这样警告就会消失。
提前致谢!
【问题讨论】:
标签: javascript node.js momentjs