MomentJS - 月份



此方法將給出時段中的月份數。它將返回 0-11 的值。要獲取給定時段中的月份長度,請使用 moment.duration().asMonths();

語法

moment.duration().months();
moment.duration().asMonths();

示例

var m = moment.duration(100, "months").months();
var asmins = moment.duration(500, "months").asMonths();

輸出

Months

此方法將給出年份數。moment.duration().asYears()獲取時段中的年數長度。

語法

moment.duration().years();
moment.duration().asYears();

示例

var m = moment.duration(500, "years").years();
var asmins = moment.duration(500, "years").asYears();

輸出

Years
momentjs_durations.htm
廣告
© . All rights reserved.