aboutsummaryrefslogtreecommitdiff
path: root/files/zh-tw/web/html/element/time/index.html
blob: ca212169dcae39469950ba1eec89e1251dc29867 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
---
title: <time>
slug: Web/HTML/Element/time
translation_of: Web/HTML/Element/time
---
<p><strong>HTML <code>&lt;time&gt;</code> element</strong> 用以表示時間,可以是24小時制時間或以<a class="external" href="https://zh.wikipedia.org/zh-tw/%E5%85%AC%E5%8E%86" title="公曆">公曆</a>紀年的日期(日期可以添加時間和時區的資訊)</p>

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

<div class="note"><strong>使用注意: </strong>此 element 不適合用在「不確定正確時間」和「時間為西元前(日期的計算會出現錯誤)」的情況。</div>

<table class="properties">
 <tbody>
  <tr>
   <th scope="row"><a href="/zh-TW/docs/Web/HTML/Content_categories" title="HTML/Content_categories">內容分類</a></th>
   <td><a href="/en-US/docs/Web/HTML/Content_categories#Flow_content" title="HTML/Content_categories#Flow_content">Flow content</a>, <a href="/en-US/docs/HTML/Content_categories#Phrasing_content" title="HTML/Content categories#Phrasing content">phrasing content</a>, palpable content.</td>
  </tr>
  <tr>
   <th scope="row">允許之內容</th>
   <td><a href="/en-US/docs/HTML/Content_categories#Phrasing_content" title="HTML/Content categories#Phrasing content">Phrasing content</a>.</td>
  </tr>
  <tr>
   <th scope="row">省略標籤</th>
   <td>
    <p>不可。</p>

    <p>起始標籤和結束標籤是強制必要的</p>
   </td>
  </tr>
  <tr>
   <th scope="row">可接受的副 elements</th>
   <td>任何接受 phrasing content 的  element。</td>
  </tr>
  <tr>
   <th scope="row">DOM interface</th>
   <td>{{domxref("HTMLTimeElement")}}</td>
  </tr>
 </tbody>
</table>

<h2 id="Attributes">Attributes</h2>

<p>和其他HTML elements一樣,接受所有 <a href="/en-US/docs/HTML/Global_attributes" title="HTML/Global attributes">global attributes</a></p>

<dl>
 <dt>{{htmlattrdef("datetime")}}</dt>
 <dd>此 attribute 用以表示日期或時間,其格式必須是<a class="external" href="http://www.w3.org/TR/html-markup/datatypes.html#common.data.datetime" title="">有效的日期/時間格式</a>。若其值不正確,則 element 就不會有關連的 time stamp.</dd>
</dl>

<h2 id="示例">示例</h2>

<h3 id="Simple_example" name="Simple_example">Simple example</h3>

<h4 id="HTML">HTML</h4>

<pre class="brush: html">&lt;p&gt;The concert starts at &lt;time&gt;20:00&lt;/time&gt;.&lt;/p&gt;
</pre>

<h4 id="Output">Output</h4>

<p>{{ EmbedLiveSample('Simple_example', 250, 60) }}</p>

<h3 id="Datetime_example" name="Datetime_example"><code>datetime</code> example</h3>

<h4 id="HTML_2">HTML</h4>

<pre class="brush: html">&lt;p&gt;The concert took place on &lt;time datetime="2001-05-15T19:00"&gt;May 15&lt;/time&gt;.&lt;/p&gt;
</pre>

<h4 id="Output_2">Output</h4>

<p>{{ EmbedLiveSample('Datetime_example', 250, 60) }}</p>

<h2 id="Specifications" name="Specifications">規格</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('HTML WHATWG', '#the-time-element', '&lt;time&gt;')}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td>No change from {{SpecName('HTML5.1')}}</td>
  </tr>
  <tr>
   <td>{{SpecName('HTML5.1', 'grouping-content.html#the-time-element', '&lt;time&gt;')}}</td>
   <td>{{Spec2('HTML5.1')}}</td>
   <td>No change from {{SpecName('HTML5 W3C')}}</td>
  </tr>
  <tr>
   <td>{{SpecName('HTML5 W3C', 'grouping-content.html#the-time-element', '&lt;time&gt;')}}</td>
   <td>{{Spec2('HTML5 W3C')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<h2 id="瀏覽器支援度">瀏覽器支援度</h2>

{{Compat("html.elements.time")}}

<h2 id="See_also" name="See_also">延伸閱讀</h2>

<ul>
 <li>The {{HTMLElement("data")}} element, allowing to signal other kind of values.</li>
</ul>

<p>{{HTMLRef}}</p>