方法 | 语法 |
创建 |
moment.duration(Number, String);
moment.duration(Number);
moment.duration(Object);
moment.duration(String);
|
clone |
moment.duration().clone();
|
humanize |
moment.duration().humanize();
|
milliseconds |
moment.duration().milliseconds();
moment.duration().asMilliseconds();
|
seconds |
moment.duration().seconds();
moment.duration().asSeconds();
|
minutes |
moment.duration().minutes();
moment.duration().asMinutes();
|
hours |
moment.duration().hours();
moment.duration().asHours();
|
days |
moment.duration().days();
moment.duration().asDays();
|
weeks |
moment.duration().weeks();
moment.duration().asWeeks();
|
months |
moment.duration().months();
moment.duration().asMonths();
|
years |
moment.duration().years();
moment.duration().asYears();
|
add |
moment.duration().add(Number, String);
moment.duration().add(Number);
moment.duration(). add(Duration);
moment.duration().add(Object);
|
subtract |
moment.duration().subtract(Number, String);
moment.duration().subtract(Number);
moment.duration()。减去(持续时间);
moment.duration().subtract(Object);
|
使用 Duration 和 Diff |
var 持续时间 = moment.duration(x.diff(y))
|
作为时间单位 |
moment.duration().as(String);
|
获取时间单位 |
duration.get('hours');
duration.get('minutes');
duration.get('seconds');
duration.get('毫秒');
|
作为 JSON |
moment.duration().toJSON();
|
是一个持续时间 |
moment.isDuration(obj);
|
作为 ISO 8601 字符串 |
moment.duration().toISOString();
|
语言环境 |
moment.duration().locale();
moment.duration().locale(String);
|