The Wayback Machine - https://web.archive.org/web/20240314105555/https://www.geeksforgeeks.org/html-datetime-attribute/
Open In App

HTML datetime Attribute

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Share
Report issue
Report

The HTML datetime attribute specifies the date and time associated with the content, facilitating machine-readable information. It’s commonly used with elements like <time> to provide structured time-related data.

Syntax

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

Attribute Values

This attribute contains a single value YYYY-MM-DDThh:mm:ssTZD which is used to specify the date and time when the text was deleted.

The explanation of datetime components is listed below:

  • YYYY: It sets the year of datetime object (e.g. 2009).
  • MM: It sets the month of datetime object (e.g. 05 for March).
  • DD: It sets the day of the month of datetime object (e.g. 04).
  • T: It is a required separator.
  • hh: It sets the hour of datetime object (e.g. 18 for 06.00pm).
  • mm: It sets the minutes of datetime object (e.g. 34).
  • ss: It sets the seconds of date
  • time object (e.g. 40).
  • ZD: Time Zone Designator (Z denotes Zulu, also known as Greenwich Mean Time)

Applicable

datetime attribute is applicable for:

<del> Represents deleted or removed text within a document.
<ins> Represents inserted or added text within a document.
<time> Represents a specific period of time or a datetime stamp.

HTML datetime Attribute Example

Example : In this example we demonstrates the <ins> tag to represent inserted or added text, marking the change from “mathematical” to “computer” in the content.

html




<!DOCTYPE html>
<html>
    <head> </head>
 
    <body>
        <h2>HTML ins Tag</h2>
 
        <p>
            GeeksforGeeks is a
            <del>mathematical</del>
            <ins datetime="2018-11-21T15:55:03Z">
                computer
            </ins>
            science portal
        </p>
    </body>
</html>


Output: 

ins

HTML datetime Attribute example output

Supported Browsers

The browsers supported by datetime Attribute are listed below: 


Last Updated : 07 Mar, 2024
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads