Posted By: Anonymous
I’m working with HTML5 elements on my webpage. By default input
type="date" shows date as
The question is, is it possible to change its format to something like:
It is impossible to change the format
We have to differentiate between the over the wire format and the browser’s presentation format.
This format is used by the
value HTML attribute and DOM property and is the one used when doing an ordinary form submission.
Browsers are unrestricted in how they present a date input. At the time of writing Chrome, Edge, Firefox, and Opera have date support (see here). They all display a date picker and format the text in the input field.
For Chrome, Firefox, and Opera, the formatting of the input field’s text is based on the browser’s language setting. For Edge, it is based on the Windows language setting. Sadly, all web browsers ignore the date formatting configured in the operating system. To me this is very strange behaviour, and something to consider when using this input type. For example, Dutch users that have their operating system or browser language set to
en-us will be shown
01/30/2019 instead of the format they are accustomed to:
Internet Explorer 9, 10, and 11 display a text input field with the wire format.
Specifically for Chrome on Android, the formatting is based on the Android display language. I suspect that the same is true for other browsers, though I’ve not been able to verify this.