Subtract Time2.1.0+
moment.duration().subtract(Number, String);
moment.duration().subtract(Number);
moment.duration().subtract(Duration);
moment.duration().subtract(Object);
Mutates the original duration by subtracting time.
The same keys and shorthands used to create durations can be used here as the second argument.
var a = moment.duration(3, 'd');
var b = moment.duration(2, 'd');
a.subtract(b).days(); // 1
Note that adding an invalid duration to any other duration results in an invalidduration.
当前内容版权归 momentjs.com 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 momentjs.com .