<time>

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

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

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

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

Attributes

和其他 HTML elements 一樣,接受所有 global attributes (en-US)

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 Standard
# the-time-element

瀏覽器支援度

BCD tables only load in the browser

延伸閱讀

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