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
廣告
© . All rights reserved.