<time>

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since October 2017.

HTML <time> element 用以表示時間,可以是 24 小時制時間或以公曆紀年的日期(日期可以添加時間和時區的資訊)

此 element 旨在以機器可讀的格式顯示時間。這能幫助使用者代理調度使用者的日期。

備註: 此 element 不適合用在「不確定正確時間」和「時間為西元前(日期的計算會出現錯誤)」的情況。

內容分類 Flow content, phrasing content, palpable content.
允許之內容 Phrasing content.
省略標籤 不可。起始標籤和結束標籤是強制必要的
可接受的副 elements 任何接受 phrasing content 的 element。
DOM interface HTMLTimeElement

Attributes

和其他 HTML elements 一樣,接受所有 global attributes

datetime

此 attribute 用以表示日期或時間,其格式必須是有效的日期/時間格式。若其值不正確,則 element 就不會有關連的 time stamp.

示例

Simple example

HTML

html
<p>The concert starts at <time>20:00</time>.</p>

Output

datetime example

HTML

html
<p>
  The concert took place on <time datetime="2001-05-15T19:00">May 15</time>.
</p>

Output

規格

Specification
HTML
# the-time-element

瀏覽器支援度

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
time
datetime

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Has more compatibility info.

延伸閱讀

  • The <data> element, allowing to signal other kind of values.