1const date = moment()
2
3date.set({
4 hour:0,
5 minute:0,
6 second:0,
7 millisecond:0
8})
1moment.duration(2, 'seconds');
2moment.duration(2, 'minutes');
3moment.duration(2, 'hours');
4moment.duration(2, 'days');
5moment.duration(2, 'weeks');
6moment.duration(2, 'months');
7moment.duration(2, 'years');
8moment.duration('2', 'years'); // from 2.25.0
9
10// or create from an object
11moment.duration({
12 seconds: 2,
13 minutes: 2,
14 hours: 2,
15 days: 2,
16 weeks: 2,
17 months: '2',
18 years: '2'
19});
20
21// or create from an iso 8601 string
22moment.duration('P1Y2M3DT4H5M6S');
23moment.duration('P1M');
24
25// duration format strings with a space between days and rest is also supported.
26moment.duration('7 23:59:59.999');
27
1var check = moment(n.entry.date_entered, 'YYYY/MM/DD');
2
3var month = check.format('M');
4var day = check.format('D');
5var year = check.format('YYYY');
1moment().set('year', 2013);
2moment().set('month', 3); // April
3moment().set('date', 1);
4moment().set('hour', 13);
5moment().set('minute', 20);
6moment().set('second', 30);
7moment().set('millisecond', 123);
8
9moment().set({'year': 2013, 'month': 3});
10