Object2.2.1+
moment({unit: value, ...});
moment({ hour:15, minute:10 });
moment({ y :2010, M :3, d :5, h :15, m :10, s :3, ms :123});
moment({ year :2010, month :3, day :5, hour :15, minute :10, second :3, millisecond :123});
moment({ years:2010, months:3, days:5, hours:15, minutes:10, seconds:3, milliseconds:123});
moment({ years:2010, months:3, date:5, hours:15, minutes:10, seconds:3, milliseconds:123});
moment({ years:'2010', months:'3', date:'5', hours:'15', minutes:'10', seconds:'3', milliseconds:'123'}); // from 2.11.0
You can create a moment by specifying some of the units in an object.
Omitted units default to 0 or the current date, month, and year.
day
and date
key both mean day-of-the-month.
date
was added in 2.8.4.
String values (as shown on the last line) are supported from version2.11.0.
Note that like moment(Array)
and new Date(year, month, date)
, months are 0 indexed.
当前内容版权归 momentjs.com 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 momentjs.com .