Time dateTimeProperty
Example
Get the data represented by the <time> element:
var x = document.getElementById("myTime").dateTime;
xThe output result is:
2014-02-14
Try it Yourself »
Definition and Usage
The dateTime property sets or returns the value of the datetime attribute of the <time> element.
The datetime attribute specifies a date or time. This attribute is used when the date or time is not specified in the content of the element.
Note:The datetime attribute does not render any special effect in any browser.
Note:The <time> element is new in HTML5.
Browser Support
![]()
![]()
![]()
![]()
![]()
Only Firefox and Opera 12 support the dateTime property.
Note:Since version 15, Opera no longer supports this property.
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 | Date or time. The components are explained below:
|
Technical Details
| Return Value: | A string, representing the date and time of the element in a computer-processable form. |
|---|
More Examples
Example
Change the date and time of the <time> element:
document.getElementById("myTime").dateTime="1999-06-24T09:30Z";
Try it Yourself »
Related Articles
HTML Reference Manual:HTML <time> datetime Attribute
Other Extensions
Time Object