Manipulate
Once you have a Moment
, you may want to manipulate it in some way. There are a number of methods to help with this.
Moment.js uses the fluent interface pattern, also known as method chaining. This allows you to do crazy things like the following.
moment().add(7, 'days').subtract(1, 'months').year(2009).hours(0).minutes(0).seconds(0);
Note: It should be noted that moments are mutable. Calling any of the manipulation methods will change the original moment.
If you want to create a copy and manipulate it, you should use moment#clone
before manipulating the moment. More info on cloning.
当前内容版权归 momentjs.com 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 momentjs.com .