diff options
Diffstat (limited to 'devdocs/html/element%2Ftime.html')
| -rw-r--r-- | devdocs/html/element%2Ftime.html | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/devdocs/html/element%2Ftime.html b/devdocs/html/element%2Ftime.html new file mode 100644 index 00000000..abf90bea --- /dev/null +++ b/devdocs/html/element%2Ftime.html @@ -0,0 +1,117 @@ +<header><h1><time>: The (Date) Time element</h1></header><div class="section-content"> +<p>The <code><time></code> <a href="../index">HTML</a> element represents a specific period in time. It may include the <code>datetime</code> attribute to translate dates into machine-readable format, allowing for better search engine results or custom features such as reminders.</p> <p>It may represent one of the following:</p> <ul> <li>A time on a 24-hour clock.</li> <li>A precise date in the <a href="https://en.wikipedia.org/wiki/Gregorian_calendar" target="_blank">Gregorian calendar</a> (with optional time and timezone information).</li> <li> +<a href="https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-duration-string" target="_blank">A valid time duration</a>.</li> </ul> +</div> +<h2 id="try_it">Try it</h2> +<div class="section-content"><iframe class="interactive is-tabbed-shorter-height" height="200" src="https://interactive-examples.mdn.mozilla.net/pages/tabbed/time.html" title="MDN Web Docs Interactive Example" loading="lazy"></iframe></div> +<h2 id="attributes">Attributes</h2> +<div class="section-content"> +<p>Like all other HTML elements, this element supports the <a href="../global_attributes">global attributes</a>.</p> <dl> <dt id="datetime"><a href="#datetime"><code>datetime</code></a></dt> <dd> <p>This attribute indicates the time and/or date of the element and must be in one of the formats described below.</p> </dd> </dl> +</div> +<h2 id="usage_notes">Usage notes</h2> +<div class="section-content"> +<p>This element is for presenting dates and times in a machine-readable format. For example, this can help a user agent offer to add an event to a user's calendar.</p> <p>This element should not be used for dates prior to the introduction of the Gregorian calendar (due to complications in calculating those dates).</p> <p>The <em>datetime value</em> (the machine-readable value of the datetime) is the value of the element's <code>datetime</code> attribute, which must be in the proper format (see below). If the element does not have a <code>datetime</code> attribute, <strong>it must not have any element descendants</strong>, and the <em>datetime value</em> is the element's child text content.</p> +</div> +<h3 id="valid_datetime_values">Valid datetime values</h3> +<div class="section-content"><dl> <dt id="a_valid_year_string"><a href="#a_valid_year_string">a valid year string</a></dt> <dd> <p><code>2011</code></p> </dd> <dt id="a_valid_month_string"><a href="#a_valid_month_string">a valid month string</a></dt> <dd> <p><code>2011-11</code></p> </dd> <dt id="a_valid_date_string"><a href="#a_valid_date_string">a valid date string</a></dt> <dd> <p><code>2011-11-18</code></p> </dd> <dt id="a_valid_yearless_date_string"><a href="#a_valid_yearless_date_string">a valid yearless date string</a></dt> <dd> <p><code>11-18</code></p> </dd> <dt id="a_valid_week_string"><a href="#a_valid_week_string">a valid week string</a></dt> <dd> <p><code>2011-W47</code></p> </dd> <dt id="a_valid_time_string"><a href="#a_valid_time_string">a valid time string</a></dt> <dd> <p><code>14:54</code></p> <p><code>14:54:39</code></p> <p><code>14:54:39.929</code></p> </dd> <dt id="a_valid_local_date_and_time_string"><a href="#a_valid_local_date_and_time_string">a valid local date and time string</a></dt> <dd> <p><code>2011-11-18T14:54:39.929</code></p> <p><code>2011-11-18 14:54:39.929</code></p> </dd> <dt id="a_valid_global_date_and_time_string"><a href="#a_valid_global_date_and_time_string">a valid global date and time string</a></dt> <dd> <p><code>2011-11-18T14:54:39.929Z</code></p> <p><code>2011-11-18T14:54:39.929-0400</code></p> <p><code>2011-11-18T14:54:39.929-04:00</code></p> <p><code>2011-11-18 14:54:39.929Z</code></p> <p><code>2011-11-18 14:54:39.929-0400</code></p> <p><code>2011-11-18 14:54:39.929-04:00</code></p> </dd> <dt id="a_valid_duration_string"><a href="#a_valid_duration_string">a valid duration string</a></dt> <dd> <p><code>PT4H18M3S</code></p> </dd> </dl></div> +<h2 id="examples">Examples</h2> + +<h3 id="simple_example">Simple example</h3> +<div class="section-content"> +<h4 id="html">HTML</h4> <div class="code-example"> +<p class="example-header"><span class="language-name">html</span></p> +<pre data-signature="9A96bUiO8BFgtvVlGZYBr+e/tr6MRVBzNdiSOEW5d50=" data-language="html"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>p</span><span class="token punctuation">></span></span>The concert starts at <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>time</span> <span class="token attr-name">datetime</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>2018-07-07T20:00:00<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>20:00<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>time</span><span class="token punctuation">></span></span>.<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>p</span><span class="token punctuation">></span></span> +</pre> +</div> <h4 id="result">Result</h4> +<div class="code-example" id="sect1"> + +<iframe class="sample-code-frame" title="Simple example sample" id="frame_simple_example" width="250" height="80" src="https://live.mdnplay.dev/en-US/docs/Web/HTML/Element/time/runner.html?id=simple_example" loading="lazy"></iframe> +</div> +</div> +<h3 id="datetime_example"> +<code>datetime</code> example</h3> +<div class="section-content"> +<h4 id="html_2">HTML</h4> <div class="code-example"> +<p class="example-header"><span class="language-name">html</span></p> +<pre data-signature="QmL9RorcB8np3iKDnCUh89LHS2dfPF/ns89Y50Le1GE=" data-language="html"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>p</span><span class="token punctuation">></span></span> + The concert took place on <span class="token tag"><span class="token tag"><span class="token punctuation"><</span>time</span> <span class="token attr-name">datetime</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>2001-05-15T19:00<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>May 15<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>time</span><span class="token punctuation">></span></span>. +<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>p</span><span class="token punctuation">></span></span> +</pre> +</div> <h4 id="result_2">Result</h4> +<div class="code-example" id="sect2"> + +<iframe class="sample-code-frame" title="datetime example sample" id="frame_datetime_example" width="250" height="80" src="https://live.mdnplay.dev/en-US/docs/Web/HTML/Element/time/runner.html?id=datetime_example" loading="lazy"></iframe> +</div> +</div> +<h2 id="technical_summary">Technical summary</h2> +<div class="section-content"><figure class="table-container"><div class="_table"><table class="properties"> <tbody> <tr> <th scope="row"><a href="../content_categories">Content categories</a></th> <td> <a href="../content_categories#flow_content">Flow content</a>, <a href="../content_categories#phrasing_content">phrasing content</a>, palpable content. </td> </tr> <tr> <th scope="row">Permitted content</th> <td> +<a href="../content_categories#phrasing_content">Phrasing content</a>.</td> </tr> <tr> <th scope="row">Tag omission</th> <td>None, both the starting and ending tag are mandatory.</td> </tr> <tr> <th scope="row">Permitted parents</th> <td> Any element that accepts <a href="../content_categories#phrasing_content">phrasing content</a>. </td> </tr> <tr> <th scope="row">Implicit ARIA role</th> <td><code><a href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/structural_roles#structural_roles_with_html_equivalents">time</a></code></td> </tr> <tr> <th scope="row">Permitted ARIA roles</th> <td>Any</td> </tr> <tr> <th scope="row">DOM interface</th> <td><a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLTimeElement"><code>HTMLTimeElement</code></a></td> </tr> </tbody> </table></div></figure></div> +<h2 id="specifications">Specifications</h2> +<div class="_table"><table class="standard-table"> +<thead><tr><th scope="col">Specification</th></tr></thead> +<tbody><tr><td><a href="https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-time-element">HTML Standard <br><small># the-time-element</small></a></td></tr></tbody> +</table></div> +<h2 id="browser_compatibility">Browser compatibility</h2> +<div class="_table"><table> +<thead> +<tr id="bct-browser-type"> +<th></th> +<th colspan="6">Desktop</th> +<th colspan="6">Mobile</th> +</tr> +<tr id="bct-browsers"> +<th></th> +<th>Chrome</th> +<th>Edge</th> +<th>Firefox</th> +<th>Internet Explorer</th> +<th>Opera</th> +<th>Safari</th> +<th>WebView Android</th> +<th>Chrome Android</th> +<th>Firefox for Android</th> +<th>Opera Android</th> +<th>Safari on IOS</th> +<th>Samsung Internet</th> +</tr> +</thead> +<tbody> +<tr> +<th><code>time</code></th> +<td class="bc-supports-yes">62</td> +<td class="bc-supports-yes">≤18</td> +<td class="bc-supports-yes">22</td> +<td class="bc-supports-no">No</td> +<td class="bc-supports-yes">4911.5–12</td> +<td class="bc-supports-yes">7</td> +<td class="bc-supports-yes">62</td> +<td class="bc-supports-yes">62</td> +<td class="bc-supports-yes">22</td> +<td class="bc-supports-yes">4611.5–12</td> +<td class="bc-supports-yes">4</td> +<td class="bc-supports-yes">8.0</td> +</tr> +<tr> +<th><code>datetime</code></th> +<td class="bc-supports-yes">62</td> +<td class="bc-supports-yes">≤18</td> +<td class="bc-supports-yes">22</td> +<td class="bc-supports-no">No</td> +<td class="bc-supports-yes">4911.5–12</td> +<td class="bc-supports-yes">7</td> +<td class="bc-supports-yes">62</td> +<td class="bc-supports-yes">62</td> +<td class="bc-supports-yes">22</td> +<td class="bc-supports-yes">4611.5–12</td> +<td class="bc-supports-yes">4</td> +<td class="bc-supports-yes">8.0</td> +</tr> +</tbody> +</table></div> +<h2 id="see_also">See also</h2> +<div class="section-content"><ul> <li>The <a href="data"><code><data></code></a> element, allowing to signal other kind of values.</li> </ul></div><div class="_attribution"> + <p class="_attribution-p"> + © 2005–2023 MDN contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br> + <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/time" class="_attribution-link">https://developer.mozilla.org/en-US/docs/Web/HTML/Element/time</a> + </p> +</div> |
