HTML Standard attribute: datetime
[this page | pdf | back links]
The HTML datetime attribute specifies the date
and time of a <del>,
<ins> or <time> element.
Valid attribute
values (when used with <del>, <ins> elements)
include:
Value
|
Description
|
YYYY-MM-DDThh:mm:ssTZD
|
A date
|
Valid attribute
values (when used with <time> elements)
include:
Value
|
Description
|
datetime
|
A machine-readable
date/time for the <time>
element
|
EXAMPLE:
HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head></head>
<body>
Created using HTML:<br>
<time datetime="2001-12-25">Christmas day, 2001</time>
<br><br>Created using JavaScript:<br>
<span id="element"></span>
<script>
var x = document.createElement("TIME");
x.setAttribute("datetime","2001-12-25")
x.textContent = "Christmas day, 2001";
document.getElementById("element").appendChild(x);
</script>
</body>
</html>
|
NAVIGATION LINKS
Contents | Prev | Next | HTML Attributes