Defaults2.2.1+
moment("15", "hh")
You can create a moment object specifying only some of the units, and the restwill be defaulted to the current day, month or year, or 0 for hours, minutes,seconds and milliseconds.
Defaulting to now, when nothing is passed:
moment(); // current date and time
Defaulting to today, when only hours, minutes, seconds and milliseconds are passed:
moment(5, "HH"); // today, 5:00:00.000
moment({hour: 5}); // today, 5:00:00.000
moment({hour: 5, minute: 10}); // today, 5:10.00.000
moment({hour: 5, minute: 10, seconds: 20}); // today, 5:10.20.000
moment({hour: 5, minute: 10, seconds: 20, milliseconds: 300}); // today, 5:10.20.300
Defaulting to this month and year, when only days and smaller units are passed:
moment(5, "DD"); // this month, 5th day-of-month
moment("4 05:06:07", "DD hh:mm:ss"); // this month, 4th day-of-month, 05:06:07.000
Defaulting to this year, if year is not specified:
moment(3, "MM"); // this year, 3rd month (March)
moment("Apr 4 05:06:07", "MMM DD hh:mm:ss"); // this year, 4th April, 05:06:07.000
当前内容版权归 momentjs.com 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 momentjs.com .