Time dateTime Property
Example
Get the date that a <time> element represents:
var x = document.getElementById("myTime").dateTime;
The result of x will be:
2014-02-14
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
The dateTime property is only supported in Firefox and Opera version 12.
Note: Opera has no longer support for this property, as of version 15.
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