The HTMLTimeElement
.dateTime
property is a DOMString
that reflects the datetime
HTML attribute, containing a machine-readable form of the element's date and time value.
The format of the string must follow one of the following HTML microsyntaxes:
Microsyntax | Description | Examples |
---|---|---|
Valid month string | YYYY- MM
|
2011-11 , 2013-05
|
Valid date string | YYYY- MM- DD
|
1887-12-01
|
Valid yearless date string | MM- DD
|
11-12
|
Valid time string | HH: MM
HH |
23:59
|
Valid local date and time string | YYYY- MM- DD HH: MM
YYYY |
2013-12-25 11:12 1972-07-25 13:43:07 1941-03-15 07:06:23.678 2013-12-25T11:12 1972-07-25T13:43:07 1941-03-15T07:06:23.678
|
Valid time-zone offset string | Z
|
Z +0200 +04:30 -0300 -08:00
|
Valid global date and time string | Any combination of a valid local date and time string followed by a valid time-zone offset string | 2013-12-25 11:12+0200 1972-07-25 13:43:07+04:30 1941-03-15 07:06:23.678Z 2013-12-25T11:12-08:00
|
Valid week string | YYYY-W WW
|
2013-W46
|
Four or more ASCII digits | YYYY | 2013 , 0001
|
Valid duration string | P dD T hH mM sS
|
P12DT7H12M13S P12DT7H12M13.3S P12DT7H12M13.45S P12DT7H12M13.455S PT7H12M13S PT7H12M13.2S PT7H12M13.56S PT7H12M13.999S 7d 5h 24m 13s
|
Syntax
dateTimeString = timeElt.dateTime; timeElt.dateTime = dateTimeString
Example
// Assumes there is <time id="t"> element in the HTML
var t = document.getElementById("t");
t.dateTime = "6w 5h 34m 5s";
Specifications
Specification | Status | Comment |
HTML Living StandardThe definition of 'HTMLTimeElement' in that specification. | Living Standard | No change from HTML 5.1. |
HTML 5.1The definition of 'HTMLTimeElement' in that specification. | Recommendation | No change from HTML5. |
HTML5The definition of 'HTMLTimeElement' in that specification. | Recommendation | Initial definition. |
Browser compatibility
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
dateTime
|
Chrome
Full support 62 |
Edge
Full support 14 |
Firefox
Full support 22 |
IE
No support No |
Opera Full support 49 Full support 49 No support 11.5 — 15 |
Safari
Full support 10 |
WebView Android
Full support 62 |
Chrome Android
Full support 62 |
Firefox Android
Full support 22 |
Opera Android Full support 46 Full support 46 No support 11.5 — 14 |
Safari iOS
Full support 10 |
Samsung Internet Android
Full support 8.0 |
Legend
- Full support
- Full support
- No support
- No support
See also
- The
HTMLTimeElement
interface it belongs to.
HTMLTimeElement.dateTime by Mozilla Contributors is licensed under CC-BY-SA 2.5.