Html 为什么 HTML5 输入类型 datetime 从已经支持它的浏览器中删除?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21263515/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 00:37:03  来源:igfitidea点击:

Why is HTML5 input type datetime removed from browsers already supporting it?

htmldatetimehtml-inputbrowser-support

提问by Patrick Hofman

I was wondering why all browsers, like Chrome versions higher than 26, which had support in the past for the input datetimeremoved it?

我想知道为什么过去支持输入的所有浏览器(例如高于 26 的 Chrome 版本)都datetime删除了它?

This sounds like a duplicate of this article, but that one is quite aged.

这听起来像是这篇文章的副本,但那篇文章已经很老了。

It looks like the HTML WG prefers datetime-local(w3c) above datetime(w3c), but why?

看起来 HTML WG 更喜欢datetime-local( w3c) 上面datetime( w3c),但为什么呢?

See thisfor feature development timeline.

请参阅功能开发时间表。

What others say:

别人怎么说:

According to mobilexweb.comit was deprecated in iOS 'because it looks too much like the datetime input type'.

mobilexweb.com 称,它在 iOS 中已被弃用,“因为它看起来太像日期时间输入类型”。

Following Google Chrome, now Safari on iOS doesn't support the datetime input type anymore and it will fallback to text. This type was deprecated in the standard in favor of datetime-local or using two inputs, date and time for the same purpose. The problem is that datetime was compatible with iOS from version 5.0 to 6.1; if you are using it, be careful!

继 Google Chrome 之后,现在 iOS 上的 Safari 不再支持 datetime 输入类型,它将回退到文本。此类型在标准中已被弃用,以支持 datetime-local 或出于相同目的使用两个输入、日期和时间。问题是 datetime 从 5.0 到 6.1 版本兼容 iOS;如果您正在使用它,请小心!

What is the difference?

有什么不同?

Where datetime-localcontains only a date and time element, datetimealso contains the time zone. This is useful since you might want to act differently when the client's time zone is different from the server's one.

wheredatetime-local只包含一个日期和时间元素,datetime还包含时区。这很有用,因为当客户端的时区与服务器的时区不同时,您可能希望采取不同的行动。

Why does this matter?

为什么这很重要?

What if the web page asks: when do you want me to call you, and the user selects 'tomorrow, 3pm', when do you need to call him back? tomorrow 3pm UTC or CET?

如果网页询问:你希望我什么时候给你打电话,而用户选择“明天,下午 3 点”,你需要什么时候给他回电话?明天下午 3 点 UTC 或 CET?

采纳答案by Patrick Hofman

The only reason I can think of is browser vendors losing faith in the standard being approved, therefore removing the implementation from their code.

我能想到的唯一原因是浏览器供应商对被批准的标准失去信心,因此从他们的代码中删除了实现。

To support this thought: W3C just removed both datetimeand datetime-localfrom their working draft.

为了支持这个想法:W3C 刚刚从他们的工作草案中删除了datetimedatetime-local

Browser vendors will eventually drop support of both of them.

浏览器供应商最终会放弃对这两者的支持。

According to html5testmost of the current browsers removed support of both of the input types.

根据html5test,当前大多数浏览器都取消了对这两种输入类型的支持。

The latest development:

最新进展:

  • The datetime-localis back on the draft;
  • The newer specs page doesn't show datetime, but it does show datetime-local. It does sound like it is back on the map and going to be supported again!
  • datetime-local是对草案备用;
  • 较新的规格页面不显示datetime,但确实显示datetime-local。听起来它确实回到了地图上,并且将再次得到支持!

Also take notice of this related post on Webmasters.SE: Is datetime-local removed from HTML 5.1?.

还要注意 Webmasters.SE 上的这篇相关帖子:是否从 HTML 5.1 中删除了 datetime-local?.

回答by Daniel

Source http://www.w3.org/TR/html5/

来源http://www.w3.org/TR/html5/

"The following features are at risk and may be removed due to lack of implementation.
..<input type=datetime>.."

“以下功能存在风险,可能会因缺乏实施而被删除
。..<input type=datetime>..”