HTML - attributes - datetime

revision:


Content

"datetime" attribute : specifies date and time syntax some examples


"datetime" attribute : specifies date and time

top

It specifies the date and time when the text was deleted/inserted. When used together with the <time> element, the "datetime attribute" represent a machine-readable format of a <time> element. The datetime attribute can be used on the following elements: <del>, <ins>, <time>.

The time element does not render as anything special in any of the major browsers. Its value is not visible to the user; it only adds a semantic timestamp to the element. "datetime values" are readable by screen readers, search engines, JavaScript code, and others.


syntax

top

<time datetime="YYYY-MM-DDThh:mm:ssTZD">

YYYY-MM-DDThh:mm:ssTZD or PTDHMS: the date or time being specified.

Explanation of components:

YYYY - year (e.g. 2011)
MM - month (e.g. 01 for January)
DD - day of the month (e.g. 08)
T or a space - a separator (required if time is also specified)
hh - hour (e.g. 22 for 10.00pm)
mm - minutes (e.g. 55)
ss - seconds (e.g. 03)
TZD - Time Zone Designator (Z denotes Zulu, also known as Greenwich Mean Time)
P - a prefix for "Period"
D - a prefix for "Days"
H - a prefix for "Hours"
M - a prefix for "Minutes"
S - a prefix for "Seconds"


some examples

top

I have a date on .

codes:
                    <p>I have a date on <time datetime="2021-02-14 20:00">Valentines day</time>.</p>
                

This is the result of a mathematical computer

HTML codes:

                    <p class="spec">This is the result of a
                        <del>mathematical</del>
                        <ins id="one" datetime="2018-11-21T15:55:03Z">computer</ins>
                        <time datetime="2017-02-14 20:00">and science proposal</time>
                    </p>
                    <style>
                        del {color: red;}
                        ins {color: green;}
                    </style>