HTML | DOM Time dateTime Property
The DOM Time dateTime Property is used to set or return the value of the DateTime attribute of the <time> Element. The date-time is inserted in the format YYYY-MM-DDThh:mm:ssTZD.
Syntax:
- It is used to return the DateTime property.
timeObject.dateTime
- It is used to set the dateTime property.
timeObject.dateTime = YYYY -MM-DDThh:mm:ssTZD
- YYYY-MM-DDThh:mm:ssTZD YYYY-MM-DDThh:mm:ssTZD It specifies the date and time.
- YYYY – year (e.g. 2009)
- MM – month (e.g. 01 for January)
- DD – day of the month (e.g. 04)
- T – a required separator
- hh – hour (e.g. 20 for 8.00pm)
- mm – minutes (e.g. 35)
- ss – seconds (e.g. 09)
- TZD – Time Zone Designator (Z denotes Zulu, also known as Greenwich Mean Time)
- HTML | <time> datetime Attribute
- HTML | DOM ins dateTime Property
- HTML | DOM del dateTime Property
- HTML | DOM Input Datetime min Property
- HTML | DOM Input Datetime name Property
- HTML | DOM Input Datetime max Property
- HTML | DOM Input Datetime value Property
- HTML | DOM Input Datetime readOnly Property
- HTML | DOM Input Datetime autofocus Property
- HTML | DOM Input Datetime disabled Property
- HTML | DOM Input Datetime form Property
- HTML | DOM Input Datetime required Property
- HTML | DOM Input Datetime type Property
- HTML | DOM Input Time max Property
- HTML | DOM Input Time name Property
Property Values:
Explanation:
Return value: It returns a string value which represent the date and time.
Example-1: This Example sets the dateTime Property.
<!DOCTYPE html> <html> <head> <title> HTML DOM Time dateTime Property </title> </head> <body style="text-align:center;"> <h1>GeeksforGeeks</h1> <h2> DOM Time dateTime Property </h2> <p> <time id="GFG" datetime="2018-11-21T15:55:03Z"> </time> </p> <button onclick="myGeeks()"> Submit </button> <p id="sudo"></p> <script> function myGeeks() { var g = document.getElementById( "GFG").dateTime = "2013-11-15T21:40:07Z"; document.getElementById("sudo").innerHTML = "The value of the dateTime attribute was changed to " + g; } </script> </body> </html> |
Output:
Before Clicking On Button:

After Clicking On Button:

Example-2:This Example returns the dateTime Property.
<!DOCTYPE html> <html> <head> <title> HTML DOM Time dateTime Property </title> </head> <body style="text-align:center;"> <h1> GeeksforGeeks </h1> <h2> DOM Time dateTime Property </h2> <time id="GFG" datetime="2018-11-21T15:55:03Z"> </time> <button onclick="myGeeks()"> Submit </button> <p id="sudo"></p> <script> function myGeeks() { var g = document.getElementById( "GFG").dateTime; document.getElementById( "sudo").innerHTML = g; } </script> </body> </html> |
Output:
Before Clicking On Button:

After Clicking On Button:

Supported Browsers: Only Firefox is the browser that supports DOM Time dateTime property.
Recommended Posts:
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



