The Wayback Machine - https://web.archive.org/web/20240306100620/https://www.geeksforgeeks.org/html-time-datetime-attribute/
Open In App
Related Articles

HTML datetime Attribute

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

The <time> datetime Attribute in HTML is used to defines the machine-readable date/time of the <time> element. The date-time is inserted in the format YYYY-MM-DDThh:mm:ssTZD. 
Syntax: 
 

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


Attribute Values: This attribute contains 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 are 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 datetime object (e.g. 40).
  • TZD: Time Zone Designator (Z denotes Zulu, also known as Greenwich Mean Time)


Example: 
 

html

<!DOCTYPE html>
<html>
  
<head>
    <title>
        HTML Time dateTime Attribute
    </title>
</head>
  
<body style="text-align:center;">
     
    <h1>GeeksforGeeks</h1>
  
    <h2>
        HTML <Time>dateTime Attribute
    </h2>
     
     
 
<p>Jawahar lal Nehru birthday is celebrated on 
        <time datetime="2018--11-14 12:00">
            children's day.
        </time>
    </p>
 
  
</body>
  
</html>

                    

Output : 
 


Supported Browsers: The browser supported by HTML <time> datetime Attribute are listed below: 
 

  • Google Chrome 62 and above
  • Edge 18 and above
  • Firefox 22 and above
  • Opera 49 and above
  • Safari 7 and above
  • Internet Explorer not supported


 


Last Updated : 19 Jul, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads
Complete Tutorials