MomentJS - 当月日期



该方法将获取/设置当月日期。它接受 1-31 的输入,如果大于提供的范围,则会添加到下个月。

语法

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

示例

var m = moment().date(); // gets the current day of the month
var d = moment().date(2); // sets the day of month as shown below
var k = moment().date(40); //sets the day of month which is greater than the
range so the output shows the next month as shown in the output

输出

Date of Month
momentjs_getter_setter.htm
广告