HTML
<time>
element
represents a specific period in time.
It may include the
datetime
attribute to translate dates into machine-readable format, allowing for better search engine results or custom features such as reminders.
It may represent one of the following:
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
| 内容类别 | 流内容 , 措词内容 ,可触及内容。 |
|---|---|
| 准许内容 | 措词内容 . |
| Tag omission | None, both the starting and ending tag are mandatory. |
| Permitted parents | Any element that accepts 措词内容 . |
| Implicit ARIA role | 无对应角色 |
| Permitted ARIA roles | 任何 |
| DOM 接口 |
HTMLTimeElement
|
Like all other HTML elements, this element supports the 全局属性 .
datetime
This attribute indicates the time and/or date of the element and must be in one of the formats described below.
This element is for presenting dates and times in a machine readable format. For example, this can help a user agent offer to add an event to a user's calendar.
This element should not be used for dates prior to the introduction of the Gregorian calendar (due to complications in calculating those dates).
datetime value
(the machine-readable value of the datetime) is the value of the element’s
datetime
attribute, which must be in the proper format (see below). If the element does not have a
datetime
属性,
it must not have any element descendants
,和
datetime value
is the element’s child text content.
2011
2011-11
2011-11-18
11-18
2011-W47
14:54
14:54:39
14:54:39.929
2011-11-18T14:54:39.929
2011-11-18 14:54:39.929
2011-11-18T14:54:39.929Z
2011-11-18T14:54:39.929-0400
2011-11-18T14:54:39.929-04:00
2011-11-18 14:54:39.929Z
2011-11-18 14:54:39.929-0400
2011-11-18 14:54:39.929-04:00
PT4H18M3S
<p>The concert starts at <time datetime="2018-07-07T20:00:00">20:00</time>.</p>
datetime
范例
<p>The concert took place on <time datetime="2001-05-15T19:00">May 15</time>.</p>
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
time
|
Chrome 完整支持 62 | Edge 完整支持 ≤18 | Firefox 完整支持 22 | IE 不支持 No | Opera 完整支持 49 | Safari 完整支持 7 | WebView Android 完整支持 62 | Chrome Android 完整支持 62 | Firefox Android 完整支持 22 | Opera Android 完整支持 46 | Safari iOS 完整支持 4 | Samsung Internet Android 完整支持 8.0 |
datetime
|
Chrome 完整支持 62 | Edge 完整支持 ≤18 | Firefox 完整支持 22 | IE 不支持 No | Opera 完整支持 49 | Safari 完整支持 7 | WebView Android 完整支持 62 | Chrome Android 完整支持 62 | Firefox Android 完整支持 22 | Opera Android 完整支持 46 | Safari iOS 完整支持 4 | Samsung Internet Android 完整支持 8.0 |
完整支持
不支持
<data>
element, allowing to signal other kind of values.