在moment.js错误的月份 [英] Getting wrong month in moment.js
本文介绍了在moment.js错误的月份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用RequireJS中包含的Moment.js。当我打电话给 Moment()。month()
时,而不是11号,我总是得到10号。任何想法怎么会发生这种情况?
I'm using Moment.js included through RequireJS. When I call Moment().month()
, instead of number 11 I always get number 10. Any ideas how can this happen?
推荐答案
根据文档,月份为零索引。因此,1月为0,12月为11. moment()。month()将给出当前月份(11月)的零指数,即10。
According to the documentation, months are zero indexed. So January is 0 and December is 11. moment().month() would give the zero based index of the current month (November) which is 10.
这篇关于在moment.js错误的月份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文