/

HTML / CSS / JavaScript Tutorial

HTML Element: <time>

[this page | pdf | back links]

The HTML <time> element indicates a (human-readable) date / time. It can be used to encode dates and times in a machine-readable fashion.

 

The attributes it can take (in addition to HTML global attributes and HTML event attributes) are:

 

Attribute

Description

More

datetime

Date and time of element

Here

 

To create or access such an element in JavaScript see here. The corresponding HTML DOM object supports standard DOM properties and methods, and additional properties with the same name and meaning as the attributes of the underlying HTML element referred to above. The default style applicable to this element is shown here.

 

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 Elements


Desktop view | Switch to Mobile