Time dateTime Property
Example
Get the date that a <time> element represents:
var x = document.getElementById("myTime").dateTime;
Try it Yourself »
Definition and Usage
The dateTime property sets or returns the value of the datetime attribute in a <time> element.
The datetime attribute gives the date or time being specified. This attribute is used if no date or time is specified in the element's content.
Note: The datetime attribute does not render as anything special in any of the major browsers.
Note: The <time> element is new in HTML5.
Browser Support
Property | |||||
---|---|---|---|---|---|
datetime | Not supported | Not supported | Yes | Not supported | Not supported |
Syntax
Return the dateTime property:
timeObject.dateTime
Set the dateTime property:
timeObject.dateTime = YYYY
-MM-DDThh:mm:ssTZD
Property Values
Value | Description |
---|---|
YYYY-MM-DDThh:mm:ssTZD | The date or time being specified. Explanation of components:
|
Technical Details
Return Value: | A String, representing a machine-readable form of the element's date and time |
---|
More Examples
Example
Change the date and time of a <time> element:
document.getElementById("myTime").dateTime = "1999-06-24T09:30Z";
Try it Yourself »
Related Pages
HTML reference: HTML <time> datetime attribute
❮ Time Object