Month1.0.0+

  1. moment().month(Number|String);
  2. moment().month(); // Number
  3. moment().months(Number|String);
  4. moment().months(); // Number

Gets or sets the month.

Accepts numbers from 0 to 11. If the range is exceeded, it will bubble up to the year.

Note: Months are zero indexed, so January is month 0.

As of 2.1.0, a month name is also supported. This is parsed in the moment's current locale.

  1. moment().month("January");
  2. moment().month("Feb");

Before version 2.1.0, if a moment changed months and the new month did not have enough days to keep the current day of month, it would overflow to the next month.

As of version 2.1.0, this was changed to be clamped to the end of the target month.

  1. // before 2.1.0
  2. moment([2012, 0, 31]).month(1).format("YYYY-MM-DD"); // 2012-03-02
  3. // after 2.1.0
  4. moment([2012, 0, 31]).month(1).format("YYYY-MM-DD"); // 2012-02-29

2.16.0 deprecated using moment().months(). Use moment().month() instead.