The HTML <time>
element represents either a time on a 24-hour clock or a precise date in the Gregorian calendar (with optional time and timezone information).
This element is intended to be used presenting dates and times in a machine readable format. This can be helpful for user agents to offer any event scheduling for user's calendar.
Usage note: This element is not appropriate for instances where a specific date cannot be calculated, nor should it be used for dates prior to the introduction to the Gregorian calendar (due to complications with calculating those dates).
Content categories | Flow content, phrasing content, palpable content. |
---|---|
Permitted content | Phrasing content, but no descendant time elements. |
Tag omission | None; both the starting and ending tags are mandatory. |
Permitted parent elements | Any element that accepts phrasing content. |
DOM interface | {{domxref("HTMLTimeElement")}} |
Attributes
Like all other HTML elements, this element supports the global attributes.
- {{htmlattrdef("datetime")}}
- This attribute indicates the time and date of the element and must be a valid date with an optional time string. If the value cannot be parsed as a date with an optional time string, the element does not have an associated time stamp.
Examples
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-15 19:00">May 15</time>.</p>
Output
{{ EmbedLiveSample('Datetime_example', 250, 60) }}
Specifications
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. |
Browser compatibility
{{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 |
See also
- The {{HTMLElement("data")}} element, allowing to signal other kind of values.
{{HTMLRef}}