--- title: slug: Web/HTML/Element/time translation_of: Web/HTML/Element/time --- HTML <time> element 用以表示時間,可以是24小時制時間或以公曆紀年的日期(日期可以添加時間和時區的資訊) 此 element 旨在以機器可讀的格式顯示時間。這能幫助使用者代理調度使用者的日期。 使用注意: 此 element 不適合用在「不確定正確時間」和「時間為西元前(日期的計算會出現錯誤)」的情況。 內容分類 Flow content, phrasing content, palpable content. 允許之內容 Phrasing content. 省略標籤 不可。 起始標籤和結束標籤是強制必要的 可接受的副 elements 任何接受 phrasing content 的 element。 DOM interface {{domxref("HTMLTimeElement")}} Attributes 和其他HTML elements一樣,接受所有 global attributes。 {{htmlattrdef("datetime")}} 此 attribute 用以表示日期或時間,其格式必須是有效的日期/時間格式。若其值不正確,則 element 就不會有關連的 time stamp. 示例 Simple example HTML <p>The concert starts at <time>20:00</time>.</p> Output {{ EmbedLiveSample('Simple_example', 250, 60) }} datetime example HTML <p>The concert took place on <time datetime="2001-05-15T19:00">May 15</time>.</p> Output {{ EmbedLiveSample('Datetime_example', 250, 60) }} 規格 Specification Status Comment {{SpecName('HTML WHATWG', '#the-time-element', '<time>')}} {{Spec2('HTML WHATWG')}} No change from {{SpecName('HTML5.1')}} {{SpecName('HTML5.1', 'grouping-content.html#the-time-element', '<time>')}} {{Spec2('HTML5.1')}} No change from {{SpecName('HTML5 W3C')}} {{SpecName('HTML5 W3C', 'grouping-content.html#the-time-element', '<time>')}} {{Spec2('HTML5 W3C')}} Initial definition. 瀏覽器支援度 {{CompatibilityTable}} Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari Basic support 33.0 {{CompatGeckoDesktop("22.0")}} 9.0 22.0 7.0 Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile Basic support 2.1 {{CompatUnknown}} {{CompatGeckoMobile("22.0")}} 10.0 11.50 Removed in 15.0 4.0-4.1 延伸閱讀 The {{HTMLElement("data")}} element, allowing to signal other kind of values. {{HTMLRef}}
HTML <time> element 用以表示時間,可以是24小時制時間或以公曆紀年的日期(日期可以添加時間和時區的資訊)
<time>
此 element 旨在以機器可讀的格式顯示時間。這能幫助使用者代理調度使用者的日期。
不可。
起始標籤和結束標籤是強制必要的
和其他HTML elements一樣,接受所有 global attributes。
<p>The concert starts at <time>20:00</time>.</p>
{{ EmbedLiveSample('Simple_example', 250, 60) }}
datetime
<p>The concert took place on <time datetime="2001-05-15T19:00">May 15</time>.</p>
{{ EmbedLiveSample('Datetime_example', 250, 60) }}
{{CompatibilityTable}}
{{HTMLRef}}