Special Formats2.7.0+

  1. moment(String, moment.CUSTOM_FORMAT, [String], [Boolean]);
  2. moment(String, moment.HTML_FMT.DATETIME_LOCAL, [String], [Boolean]); // from 2.20.0
  3. moment(String, [..., moment.ISO_8601, ...], [String], [Boolean]);

ISO-8601 is a standard for time and duration display. Moment already supports parsing iso-8601 strings, but this can be specified explicitly in the format/list of formats when constructing a moment.

To specify iso-8601 parsing use moment.ISO_8601 constant.

  1. moment("2010-01-01T05:06:07", moment.ISO_8601);
  2. moment("2010-01-01T05:06:07", ["YYYY", moment.ISO_8601]);

As of version 2.20.0, the following HTML5 formats are available:

ConstantFormatExampleInput Type
moment.HTML5_FMT.DATETIME_LOCALYYYY-MM-DDTHH:mm2017-12-14T16:34<input type="datetime-local" />
moment.HTML5_FMT.DATETIME_LOCAL_SECONDSYYYY-MM-DDTHH:mm:ss2017-12-14T16:34:10<input type="datetime-local" step="1" />
moment.HTML5_FMT.DATETIME_LOCAL_MSYYYY-MM-DDTHH:mm:ss.SSS2017-12-14T16:34:10.234<input type="datetime-local" step="0.001" />
moment.HTML5_FMT.DATEYYYY-MM-DD2017-12-14<input type="date" />
moment.HTML5_FMT.TIMEHH:mm16:34<input type="time" />
moment.HTML5_FMT.TIME_SECONDSHH:mm:ss16:34:10<input type="time" step="1" />
moment.HTML5_FMT.TIME_MSHH:mm:ss.SSS16:34:10.234<input type="time" step="0.001" />
moment.HTML5_FMT.WEEKYYYY-[W]WW2017-W50<input type="week" />
moment.HTML5_FMT.MONTHYYYY-MM2017-12<input type="month" />