📅  最后修改于: 2023-12-03 15:17:41.050000             🧑  作者: Mango
moment.add()
is a method in the moment.js library that allows you to add time to a given moment object. This method is very useful for time calculations in Javascript.
moment.add(Number, String);
The first parameter represents the amount of time to add, while the second parameter represents the unit of time.
The moment.add()
method returns a new moment object with the added time.
// Add 1 day to the current date
var today = moment();
var tomorrow = today.add(1, 'days');
// Add 1 hour to the current time
var now = moment();
var later = now.add(1, 'hours');
// Add 2 weeks to a specific date
var specificDate = moment('2021-10-01');
var futureDate = specificDate.add(2, 'weeks');
moment.add()
is a very useful method in the moment.js library that allows you to easily add time to a moment object. This method can be used for a wide range of time calculations in your Javascript projects.