HTML time tag

HTML <time> tag defines time with the machine-readable value of time and date values.


<p>Time: <time>15:35</time></p>
 <p>Time: <time>15:35:22.722</time></p>
 <p>Date: <time>2016-12-05</time></p>

Try </>

You may consider we don't need to use time tag. But it has been specially designed for time and date purposes. So that system or machine read it as date and time.

  • The values of the datetime value may differ.

  • In the value, we first write year.

  • After the year, a month is written.

  • After the month, the day of the month is written.

  • To write time along the date, write 'T'.

  • Then write hours: minutes: seconds.

You can see the value of datetime attribute in the following example.

Tag omission

Both ending and starting tags are necessary for the time element.

Global Attributes

All the global attributes are applicable on the time element.

Specific Attributes

datetime defines machine readable date and time value.
<time datetime="2012-05-08T15:54:25">2012-08-05/time>

Was this article helpful?




Get the newsletter