HTML 时间标签 - 正确的日期格式 [英] HTML time tag - correct date format

查看:106
本文介绍了HTML 时间标签 - 正确的日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用正确的格式和标准将时间标签放入我的 html 文档中.

I am wanting to use the correct format and standards to put the time tag in my html document.

这是正确的做法吗?

<time datetime="2014-03-26T12:48:42.733Z">26/03/2014</time>

谢谢

推荐答案

time 在 HTML5 中定义的元素必须以特定的机器可读格式指定时间、日期、时间和日期或其他适用的名称,如草稿.此名称可能显示为元素内容,例如

The time element as defined in HTML5 must specify time, date, time and date, or other applicable designation in a specific machine-readable format, as described in the draft. This designation may appear as the element content, e.g.

<time>2014-03-26></time>

如果不是(通常,当内容以某种语言以人类可读的形式指定日期或时间时),机器可读的指定必须作为 datetime 属性的值出现,例如

If it does not (typically, when the content specifies a date or time in human-readable form in some language), the machine-readable designation must appear as the value of the datetime attribute, e.g.

<time datetime="2014-03-26">26/03/2014</time>

问题中的表示法不充分,因为属性的值必须是以机器可读格式表示的元素内容",而日期和时间表示法,精确到毫秒,很难说表示日期.

The notation in the question is not adequate, as the value of the attribute must be "a representation of the element's contents in a machine-readable format", and a date and time denotation, down to milliseconds, can hardly be said to represent a date.

注意:没有证据表明浏览器或搜索引擎会使用 time 标记,因此此类标记仅具有潜在用途.

Note: There is no evidence of browsers or search engines making any use of time markup, so such markup is only potentially useful.

这篇关于HTML 时间标签 - 正确的日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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