Moment.js should support HTML5 inputs like datetime-local #3928
Closed
Description
Moment.js should support out of the box HTML5 inputs datetime-local, date, time, week, month.
Instead of writing:
<input type="datetime-local" value={start.format('YYYY-MM-DDTHH:mm')} />
<input type="date" value={start.format('YYYY-MM-DD')} />
<input type="time" value={start.format('HH:mm:ss')} />
something like:
<input type="datetime-local" value={start.toHtmlInput_datetime_local()} />
<input type="date" value={start.toHtmlInput_date()} />
<input type="time" value={start.toHtmlInput_time()} />
<input type="week" value={start.toHtmlInput_week()} />
<input type="month" value={start.toHtmlInput_month()} />
=> more explicit, less error-prone (ss vs SS, local vs UTC, yyyy vs YYYY...)
datetime-local
expects "yyyy-MM-ddThh:mm" followed by optional ":ss" or ":ss.SSS" format
date
expects "yyyy-MM-dd"
time
expects "HH:mm", "HH:mm:ss" or "HH:mm:ss.SSS"
week
expects "yyyy-Www"
month
expects "yyyy-MM"
(taken from error messages given by Chrome 57. Yes Chrome speaks yyyy and dd instead of YYYY and DD, see #1603)