HTML time Tag

The HTML <time> element is utilized for indicating specific dates and times. It showcases time information in a 24-hour format or an exact date according to the Gregorian calendar within an HTML document.

It is employed to encode dates and times in a format readable by machines, facilitating the marking or scheduling of tasks.

It additionally assists search engines in generating more intelligent search outcomes.

HTML <time> represents the latest addition to the HTML language, having been introduced with the HTML5 specification.

Let's see the syntax to define date and time.

Example

<time>Define Time and Date here</time>

Attribute

There is just a single particular attribute associated with the HTML5 time element.

Attribute Description
datetime It is used to define machine-readable date/time within the time element.

HTML time tag example

Example

<p>We open our shop at <time>09:00</time> am.</p>

<p>The business meeting is scheduled on <time datetime="2009-02-18">next wednesday</time>.</p>

<p>The wedding of Salman's sister was scheduled  at <time datetime="2014-11-19 T0 7:00-09:00">7pm last wednesday </time>.</p>

Output:

We open our shop at 09:00 am.

The corporate gathering is planned for the upcoming Wednesday.

Salman's sister's wedding was planned for 7:00 PM last Wednesday.

In this instance, the initial line within the body tag explains the fundamental application of the time tag.

The following line demonstrates the utilization of the datetime attribute to present information in a format that can be understood by machines.

The third line utilizes the datetime attribute to offer a more precise date and time.

The <time> tag in HTML 5 also accommodates global attributes and event attributes.

Supporting Browsers

Element Chrome IE Firefox Opera Safari
<time> Yes Yes Yes Yes Yes

Input Required

This code uses input(). Please provide values below: