It is impossible to change the format
(无法更改格式)
We have to differentiate between the over the wire format and the browser's presentation format.
(我们必须区分有线格式和浏览器的演示格式。)
Wire format (电汇格式)
The HTML5 date input specification refers to the RFC3339 specification , which specifies a full-date format equal to: yyyy-mm-dd
.
(所述HTML5日期输入规范指的是RFC3339规范 ,它指定一个全日期格式等于: yyyy-mm-dd
。)
See section 5.6 of the RFC3339 specification for more details. (有关更多详细信息,请参见RFC3339规范的5.6节 。)
Presentation format (简报格式)
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 ). (在撰写本文时,Chrome,Edge,Firefox和Opera具有日期支持(请参阅此处 )。)
They all display a date picker and format the text in the input field. (它们都显示日期选择器,并在输入字段中设置文本格式。)
Desktop devices
(桌面设备)
For Chrome, Firefox, and Opera, the formatting of the input field's text is based on the browser's language setting.
(对于Chrome,Firefox和Opera,输入字段文本的格式基于浏览器的语言设置。)
For Edge, it is based on the Windows language setting. (对于Edge,它基于Windows语言设置。)
Sadly, all web browsers ignore the date formatting configured in the operating system. (可悲的是,所有Web浏览器都忽略了操作系统中配置的日期格式。)
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: 30-01-2019
. (例如,将其操作系统或浏览器语言设置为en-us
荷兰用户将显示01/30/2019
而不是他们习惯的格式: 30-01-2019
。)
Internet Explorer 9, 10, and 11 display a text input field with the wire format.
(Internet Explorer 9、10和11以有线格式显示文本输入字段。)
Mobile devices
(移动设备)
Specifically for Chrome on Android, the formatting is based on the Android display language.
(专门针对Android上的Chrome,格式基于Android显示语言。)
I suspect that the same is true for other browsers, though I've not been able to verify this. (我怀疑其他浏览器也是如此,尽管我无法对此进行验证。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…