Time dateTime Attribute
Definition and Usage
dateTime
Sets or returns the value of the datetime attribute of the <time> element.
<time> datetime attribute Provide the specified date or time. If the content of the element does not specify a date or time, use this attribute.
Note:The datetime attribute will not be displayed as any special effect in any mainstream browser.
See also:
HTML Reference Manual:HTML <time> Tag
Example
Example 1
Get the date represented by the <time> element:
var x = document.getElementById("myTime").dateTime;
Example 2
Change the date and time of the <time> element:
document.getElementById("myTime").dateTime = "2023-08-22T18:00Z";
Syntax
Return dateTime attribute:
timeObject.dateTime
Set dateTime attribute:
timeObject.dateTime = YYYY-MM-DDThh:mm:ssTZD
Attribute Value
Value | Description |
---|---|
YYYY-MM-DDThh:mm:ssTZD |
Specified date or time. Component Description:
|
Technical Details
Return Value: | A string value representing the machine-readable form of the element's date and time. |
---|
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Not Supported | Not Supported | Supported | Not Supported | Not Supported |
Related Pages
HTML Reference Manual:HTML <time> datetime Attribute