date()


moment().date(Number);
moment().date(); // 数字
moment().dates(Number);
moment().dates(); // 数字

获取或设置月份的日期。

接受 1 到 31 之间的数字。 如果超出范围,则它将会冒泡达到月份。

注意:Moment#date 是月份的日期,而 Moment#day 是星期几。

注意:如果链接多个操作以构造一个日期,则应从年份、月份、日期等依次开始。 否则,可能会得到意外的结果,例如,当 day=31 并且当前月份只有 30 天时(同样适用于原生 JavaScript Date 的操作),返回的日期将会为当前月份的 30 号(有关详情,参阅月份)。

错误:moment().date(day).month(month).year(year)

正确:moment().year(year).month(month).date(day)

2.16.0 起废弃使用 moment().dates()。 改用 moment().date()

moment().date(Number);
moment().date(); // Number
moment().dates(Number);
moment().dates(); // Number

Gets or sets the day of the month.

Accepts numbers from 1 to 31. If the range is exceeded, it will bubble up to the months.

Note: Moment#date is for the date of the month, and Moment#day is for the day of the week.

Note: if you chain multiple actions to construct a date, you should start from a year, then a month, then a day etc. Otherwise you may get unexpected results, like when day=31 and current month has only 30 days (the same applies to native JavaScript Date manipulation), the returned date will be the 30th of the current month (see month for more details).

Bad: moment().date(day).month(month).year(year)

Good: moment().year(year).month(month).date(day)

2.16.0 deprecated using moment().dates(). Use moment().date() instead.