<time>
element is a date, time, or time period represented in a machine-readable format. It can be useful for creating schedules, archives or other functions related to time. WordPress uses this element in the basic theme. Another example of using <time>
is Reddit:<time>
can be used as a regular HTML tag. Here is a simple example that presents November 2011: <time>2011-11</time>
datetime
attribute (which will be discussed in more detail later). However, this is completely optional. This value can be moved to the attribute specified explicitly, and arbitrary text can be used inside the tag: <time datetime="2011-11">A cold winter month many years ago</time>
datetime
attribute that gives this element its unique properties. It represents in the machine-readable form any date, time or interval relating to the text inside the tag. Since it is intended for computers, its format is strictly defined. <time datetime="2011-11">November, 2011</time>
datetime
formatting. 2014-06
1969-07-16
12-31
14:54:39.929
2013-11-20T14:54
+06:00
2019-12-31T23:59:59-02:00
2010-W21
1776
"0001"
, "12345"
. P2DT2H30M10.501S
1w 2d 2h 30m 10.501s
Google released Gmail Blue on <time datetime="2013-04-01">April 1st, 2013</time>.
The Chelyabinsk meteor entered Earth's atmosphere over Russia on <time datetime="2013-02-15T09:20+06:00">15 February 2013 at about 09:20 YEKT (03:20 UTC)</time>.
The Apollo 13 mission lasted a total of <time datetime="5d 22h 54m 41s">5 days, 22 hours, 54 minutes, and 41 seconds</time>.
<time>
:<time>
element has no browser support issues. If the browser is familiar with the element, it will process it; if not, it will perceive it as an unknown inline element, which suits us perfectly. The datetime
attribute is also easily accessible.<time>
element. You can get the dateTime
value via the element reference: <p>The concert took place on <time datetime="2001-05-15 19:00">May 15</time>.</p> <script> var time = document.getElementsByTagName("time")[0]; console.log(time.dateTime); // outputs "2001-05-15 19:00" </script>
datetime
attribute, and it doesn’t even know how to recognize the correct time values ​​inside the tag, which would be logical enough.Options for the use of a clear date to come up with it is not difficult. The browser can prompt the user to add an event on the page to his calendar. Thailand’s browser can automatically convert the date in the Gregorian calendar to a traditional Buddhist calendar. A Japanese browser may show<time>16:00</time>
as "16:00". Content aggregators can automatically generate a timeline of events.
Search engines can improve issue results. For example, recently there was a heavy snowfall, I googled and found that the school my children go to is closed today. It was only when the school called and asked why my children did not come, I found that at the bottom of the page with the news about the closure of the school is written in small print: "Published on January 5, 2008". Search engines could well have recent events higher in the issue.
<time>
element by adding the title
attribute, in which you specify more detailed information. That is, time data can be presented in three forms at once: <time datetime="<%= @pen.created_at.strftime("%Y-%m-%dT%H:%M") %>" title="<%= @pen.created_at.strftime("%Y-%m-%d at %I:%M %p") %>"> <%= @pen.created_at.strftime("%B %d, %Y") %> </time>
Source: https://habr.com/ru/post/229291/
All Articles