aboutsummaryrefslogtreecommitdiff
path: root/files/zh-tw/web/html/element/time/index.html
blob: 53fac916a8ef80eedb878ae86e873fe086f2371b (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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
---
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>

<p>{{CompatibilityTable}}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>33.0</td>
   <td>{{CompatGeckoDesktop("22.0")}}</td>
   <td>9.0</td>
   <td>22.0</td>
   <td>7.0</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Chrome for Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>2.1</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoMobile("22.0")}}</td>
   <td>10.0</td>
   <td>11.50<br>
    Removed in 15.0</td>
   <td>4.0-4.1</td>
  </tr>
 </tbody>
</table>
</div>

<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>