有没有办法改变输入类型=“日期”格式? [英] Is there any way to change input type="date" format?

查看:216
本文介绍了有没有办法改变输入类型=“日期”格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在我的网页上使用HTML5元素。默认情况下,输入 type =date显示日期为 YYYY-MM-DD



问题是可以将其格式更改为: DD-MM-YYYY

解决方案

无法更改格式



我们必须区分线上格式和浏览器的演示格式。



线格式 HTML5日期输入规范[1]是指RFC3339规范[2],其规定了等于yyyy-mm-dd的全日格式。有关更多详细信息,请参见RFC3339规范的第5.6节。



演示文稿格式浏览器在显示日期输入方面不受限制。在撰写Chrome [3]和Microsoft Edge时,有最广泛的日期支持。它们使用用户的本地日历格式显示日期选择器。 Opera 10.6+还显示日期选择器,但以线格式显示日期。其他浏览器,如Firefox 51.0.1和Internet Explorer 9/10/11显示带有格式的文本输入字段。



参考文献




  1. http: //www.w3.org/TR/html-markup/input.date.html

  2. http://tools.ietf.org/html/rfc3339

  3. https://plus.google.com/102860501900098846931/posts/hTcMLVNKnec


I'm working with HTML5 elements on my webpage. By default input type="date" shows date as YYYY-MM-DD.

The question is, is it possible to change it's format to something like: DD-MM-YYYY?

解决方案

There is no way possible 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 [1] refers to the RFC3339 specification [2], which specifies a full-date format equal to: yyyy-mm-dd. See section 5.6 of the RFC3339 specification for more details.

Presentation format Browsers are unrestricted in how they present a date input. At the time of writing Chrome [3] and Microsoft Edge have the most extensive date support. They displays a date picker using the user's local calendar format. Opera 10.6+ also displays a date picker, but shows the date in the wire format. Other browsers, such as Firefox 51.0.1 and Internet Explorer 9/10/11 display a text input field with the wire format.

References

  1. http://www.w3.org/TR/html-markup/input.date.html
  2. http://tools.ietf.org/html/rfc3339
  3. https://plus.google.com/102860501900098846931/posts/hTcMLVNKnec

这篇关于有没有办法改变输入类型=“日期”格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆