Horje

How to add HTML <time> datetime Attribute

It is A time element with a machine-readable datetime attribute.

Definition and Usage.
The datetime attribute represent a machine-readable format of a <time> element.

Browser Support

Syntax

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

Attribute Values

Value Description
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"
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The time datetime attribute</h1>

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

<p><b>Note:</b> The time element does not render as anything special in any of the major browsers.</p>

</body>
</html>

Output should be:

How to add HTML <time> datetime Attribute




Type:
html
Category:
Web Tutorial
Sub Category:
HTML Tag
Uploaded by:
Admin