diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/html/element/time | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/html/element/time')
-rw-r--r-- | files/zh-cn/web/html/element/time/index.html | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/files/zh-cn/web/html/element/time/index.html b/files/zh-cn/web/html/element/time/index.html new file mode 100644 index 0000000000..7c96c6d567 --- /dev/null +++ b/files/zh-cn/web/html/element/time/index.html @@ -0,0 +1,137 @@ +--- +title: <time> +slug: Web/HTML/Element/time +translation_of: Web/HTML/Element/time +--- +<h2 id="概述">概述</h2> + +<p> HTML <em>time</em> 标签(<code><time></code>) 用来表示24小时制时间或者<a class="external" href="http://en.wikipedia.org/wiki/Gregorian_calendar" title="http://en.wikipedia.org/wiki/Gregorian_calendar">公历日期</a>,若表示日期则也可包含时间和时区。</p> + +<p>此元素意在以机器可读的格式表示日期和时间。 有安排日程表功能的应用可以利用这一点。</p> + +<div class="note"><strong>用法提示: </strong>如果给定的日期不是正常日期或者在公历中最早的日期之前,请不要使用此元素。</div> + +<div class="note"><strong>状态提示</strong>: <span class="long_text short_text" id="result_box" lang="zh-CN"><span>该元素</span><span>仍在</span><span>设计</span><span>和</span><span>讨论中</span></span>(<a class="external" href="http://blog.whatwg.org/weekly-time-data" title="http://blog.whatwg.org/weekly-time-data">http://blog.whatwg.org/weekly-time-data</a>)</div> + +<h3 id="使用场景"><span class="long_text short_text" id="result_box" lang="zh-CN"><span>使用场景</span></span></h3> + +<table class="standard-table"> + <tbody> + <tr> + <td><a href="/zh-cn/HTML/Content_categories" title="zh-cn/HTML/Content categories">内容分类</a></td> + <td><a href="/zh-cn/HTML/Content_categories#flow_content" title="zh-cn/HTML/Content categories#flow content">flow content</a>, <a href="/zh-cn/HTML/Content_categories#phrasing_content" title="zh-cn/HTML/Content categories#phrasing content">phrasing content</a></td> + </tr> + <tr> + <td>可包含内容</td> + <td><a href="/zh-cn/HTML/Content_categories#Phrasing_content" title="zh-cn/HTML/Content categories#Phrasing content">Phrasing content</a>, 但不能包含子 <code>time</code> 元素。</td> + </tr> + <tr> + <td>标签可省略?</td> + <td>起止标签均不能省略。</td> + </tr> + <tr> + <td>允许的父元素</td> + <td>任何接受 phrasing content 的元素。</td> + </tr> + <tr> + <td>标准文档</td> + <td><a class="external" href="http://www.whatwg.org/specs/web-apps/current-work/multipage/text-level-semantics.html#the-time-element" rel="external nofollow" title="http://www.whatwg.org/specs/web-apps/current-work/multipage/text-level-semantics.html#the-time-element">HTML5, section 4.6.10</a></td> + </tr> + </tbody> +</table> + +<h3 id="属性">属性</h3> + +<p>像所有其他元素一样,此元素拥有可以使用 <a href="/zh-cn/HTML/Global_attributes" title="zh-cn/HTML/Global attributes">通用属性</a>。</p> + +<dl> + <dt>{{ htmlattrdef("datetime") }}</dt> + <dd>该属性表示此元素的时间和日期,并且属性值必须是一个<a class="external" href="http://www.w3.org/TR/html5/common-microsyntaxes.html#valid-date-string-with-optional-time" title="http://www.w3.org/TR/html5/common-microsyntaxes.html#valid-date-string-with-optional-time">有效的日期格式,并可包含时间</a>。 如果此值不能被解析为日期,元素不会有一个关联的时间戳.</dd> + <dt>{{ htmlattrdef("pubdate") }}</dt> + <dd>(该属性仍在被WHATWG 和 W3C组织设计和讨论中.) This Boolean attribute specifies that the date and time given by the element is the publication date of a document. The document it applies to is either the nearest ancestor article element or the document as a whole (if there is no ancestor <a href="/zh-cn/HTML/Element/article" title="zh-cn/HTML/Element/Article">article</a> element). If true, the <code>time</code> element must have a corresponding date. Additionally, each <code>time</code> element indicating a publication date must be the only <code>time</code> element that does so for that document.</dd> +</dl> + +<h3 id="DOM_接口">DOM 接口</h3> + +<p>该元素实现了 <code><a href="/zh-cn/DOM/HTMLTimeElement" title="zh-cn/DOM/HTMLTimeElement">HTMLTimeElement</a></code> 接口。</p> + +<h3 id="例子">例子</h3> + +<pre class="brush: html"><p>The concert starts at <time>20:00</time>.</p> +</pre> + +<p>上面的HTML会显示:</p> + +<p>The concert starts at 20:00.</p> + +<h4 id="Pubdate_example" name="Pubdate_example"><code>pubdate</code> 示例</h4> + +<pre class="brush: html"><article> + <p>This article was created on <time pubdate>2011-01-28</time>.</p> +</article> +</pre> + +<p>上面的HTML会显示:</p> + +<p>This article was created on 2011-01-28.</p> + +<h4 id="Datetime_example" name="Datetime_example"><code>datetime</code> 示例</h4> + +<pre class="brush: html"><p>The concert took place on <time datetime="2001-05-15 19:00">May 15</time>.</p> +</pre> + +<p>上面的HTML会显示:</p> + +<p>The concert took place on May 15.</p> + +<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>{{ CompatUnknown() }}</td> + <td>{{ CompatNo() }} {{ bug("629801") }}</td> + <td>{{ CompatUnknown() }}</td> + <td>11.50</td> + <td>{{ CompatUnknown() }}</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>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>{{ CompatUnknown() }}</td> + <td>{{ CompatNo() }}</td> + <td>{{ CompatUnknown() }}</td> + <td>{{ CompatUnknown() }}</td> + <td>{{ CompatUnknown() }}</td> + </tr> + </tbody> +</table> +</div> + +<p>{{ languages( { "en": "en/HTML/HTML_Elements/time"} ) }}</p> |