Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

<time>: The (Date) Time element

BaselineWidely available

The<time>HTML element represents a specific period in time. It may include thedatetime attribute to translate dates into machine-readable format, allowing for better search engine results or custom features such as reminders.

It may represent one of the following:

Try it

<p>  The Cure will be celebrating their 40th anniversary on  <time datetime="2018-07-07">July 7</time> in London's Hyde Park.</p><p>  The concert starts at <time datetime="20:00">20:00</time> and you'll be able  to enjoy the band for at least <time datetime="PT2H30M">2h 30m</time>.</p>
time {  font-weight: bold;}

Attributes

Like all other HTML elements, this element supports theglobal attributes.

datetime

This attribute indicates the time and/or date of the element and must be in one of the formats described below.

Usage notes

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.

This element should not be used for dates prior to the introduction of the Gregorian calendar (due to complications in calculating those dates).

Thedatetime value (the machine-readable value of the datetime) is the value of the element'sdatetime attribute, which must be in the proper format (see below). If the element does not have adatetime attribute,it must not have any element descendants, and thedatetime value is the element's child text content.

Valid datetime values

DescriptionMicrosyntaxExamples
Valid month stringYYYY-MM2011-11,2013-05
Valid date stringYYYY-MM-DD1887-12-01
Valid yearless date stringMM-DD11-12
Valid time stringHH:MM
HH:MM:SS
HH:MM:SS.mmm
23:59
12:15:47
12:15:52.998
Valid local date and time stringYYYY-MM-DDHH:MM
YYYY-MM-DDHH:MM:SS
YYYY-MM-DDHH:MM:SS.mmm
YYYY-MM-DDTHH:MM
YYYY-MM-DDTHH:MM:SS
YYYY-MM-DDTHH:MM:SS.mmm
2013-12-25 11:12
1972-07-25 13:43:07
1941-03-15 07:06:23.678
2013-12-25T11:12
1972-07-25T13:43:07
1941-03-15T07:06:23.678
Valid time-zone offset stringZ
+HHMM
+HH:MM
-HHMM
-HH:MM
Z
+0200
+04:30
-0300
-08:00
Valid global date and time string Any combination of a valid local date and time string followed by a valid time-zone offset string2013-12-25 11:12+0200
1972-07-25 13:43:07+04:30
1941-03-15 07:06:23.678Z
2013-12-25T11:12-08:00
Valid week stringYYYY-WWW2013-W46
Four or more ASCII digitsYYYY2013,0001
Valid duration stringPdDThHmMsS
PdDThHmMs.XS
PdDThHmMs.XXS
PdDThHmMs.XXXS
PThHmMsS
PThHmMs.XS
PThHmMs.XXS
PThHmMs.XXXS
wwddhhmmss
P12DT7H12M13S
P12DT7H12M13.3S
P12DT7H12M13.45S
P12DT7H12M13.455S
PT7H12M13S
PT7H12M13.2S
PT7H12M13.56S
PT7H12M13.999S
7d 5h 24m 13s

Examples

Basic example

HTML

html
<p>The concert starts at <time datetime="2018-07-07T20:00:00">20:00</time>.</p>

Result

datetime example

HTML

html
<p>  The concert took place on <time datetime="2001-05-15T19:00">May 15</time>.</p>

Result

Technical summary

Content categoriesFlow content,phrasing content, palpable content.
Permitted contentPhrasing content.
Tag omissionNone, both the starting and ending tag are mandatory.
Permitted parents Any element that acceptsphrasing content.
Implicit ARIA roletime
Permitted ARIA rolesAny
DOM interfaceHTMLTimeElement

Specifications

Specification
HTML
# the-time-element

Browser compatibility

See also

  • The<data> element, allowing to signal other kind of values.

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp