Time dateTime
Attribute
Example
Retrieve the data represented by the <time>
element:
x Output result:
Definition and Usage
The dateTime
attribute sets or returns the value of the datetime
attribute of a <time>
element.
The datetime
attribute specifies the date or time. This attribute is used when the date or time is not specified within the content of the element.
Note: The datetime
attribute does not render any special effects in any browser.
Note: The <time>
element is new in HTML5.
Browser Support
Only Firefox and Opera 12 support the dateTime
attribute.
Note: Opera no longer supports this attribute since version 15.
Syntax
Return the dateTime
attribute:
Set the dateTime
attribute:
Attribute Values
Value | Description |
---|---|
YYYY-MM-DDThh:mm:ssTZD | Date or time. The components are explained below: YYYY - Year (e.g., 2011)<br> MM - Month (e.g., 01 for January)<br> DD - Day of the month (e.g., 08)<br> T - Required separator if time is specified<br> hh - Hour (e.g., 22 for 10:00pm)<br> mm - Minute (e.g., 55)<br> ss - Second (e.g., 03)<br> TZD - Time zone identifier (Z stands for Zulu, also known as Greenwich Mean Time) |
Technical Details
| Return Value: | String, representing the machine-readable format of the date and time of the element. | | --- | --- |
More Examples
Example
Change the date and time of a <time>
element:
Related Articles
HTML Reference: HTML <time>
datetime Attribute