content
content copied to clipboard
Clarify how to format a datetime-local value
Summary
Motivation
The existing language suggests that one can take a Date
object, call toISOString()
on it, and use the resulting string as the value for a datetime-local input. This doesn't work, because toISOString()
includes a "Z
" at the end to indicate the timezone, while datetime-local expects the value to have no time-zone offset information.
Supporting details
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString describes the behavior of toISOString returning a value ending in Z. https://html.spec.whatwg.org/dev/input.html#local-date-and-time-state-(type=datetime-local) defines how datetime-local works and specifies that the value (if not empty) must be a valid local date and time string, which doesn't include timezone information (https://html.spec.whatwg.org/dev/common-microsyntaxes.html#valid-local-date-and-time-string defines "valid local date and time string").
Related issues
Metadata
- [ ] Adds a new document
- [ ] Rewrites (or significantly expands) a document
- [x] Fixes a typo, bug, or other error
Preview URLs
Flaws
URL: /en-US/docs/Web/HTML/Element/input/datetime-local
Title: <input type="datetime-local">
on GitHub
Flaw count: 2
-
macros:
-
wrong xref macro used (consider changing which macro you use)
-
-
broken_links:
-
Link points to the page it's already on
-
External URLs
URL: /en-US/docs/Web/HTML/Element/input/datetime-local
Title: <input type="datetime-local">
on GitHub
No new external URLs
Nick, thanks much for catching this and fixing it, and congrats on landing your first docs change here — welcome aboard 🎉