HTMLTimeElement
.dateTime
特性为
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 | 描述 | 范例 |
|---|---|---|
| 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
:
MM
:
SS
HH
:
MM
:
SS
.
mmm
|
23:59
12:15:47
12:15:52.998
|
| Valid local date and time string |
YYYY
-
MM
-
DD
HH
:
MM
YYYY
-
MM
-
DD
HH
:
MM
:
SS
YYYY
-
MM
-
DD
HH
:
MM
:
SS
.
mmm
YYYY
-
MM
-
DD
T
HH
:
MM
YYYY
-
MM
-
DD
T
HH
:
MM
:
SS
YYYY
-
MM
-
DD
T
HH
:
MM
:
SS
.
mmm
|
2013-12-25 11:12
|
| Valid time-zone offset string |
Z
+
HHMM
+
HH
:
MM
-
HHMM
-
HH
:
MM
|
Z
|
| 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
|
| Valid week string |
YYYY
-W
WW
|
2013-W46
|
| Four or more ASCII digits | YYYY |
2013
,
0001
|
| Valid duration string |
P
d
D
T
h
H
m
M
s
S
P
d
D
T
h
H
m
M
s
.
X
S
P
d
D
T
h
H
m
M
s
.
XX
S
P
d
D
T
h
H
m
M
s
.
XXX
S
P
T
h
H
m
M
s
S
P
T
h
H
m
M
s
.
X
S
P
T
h
H
m
M
s
.
XX
S
P
T
h
H
m
M
s
.
XXX
S
w
w
d
d
h
h
m
m
s
s
|
P12DT7H12M13S
|
dateTimeString = timeElt.dateTime; timeElt.dateTime = dateTimeString
// Assumes there is <time id="t"> element in the HTML
var t = document.getElementById("t");
t.dateTime = "6w 5h 34m 5s";
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
dateTime
|
Chrome 62 | Edge 14 | Firefox 22 | IE 不支持 No |
Opera
49
|
Safari 10 | WebView Android 62 | Chrome Android 62 | Firefox Android 22 |
Opera Android
46
|
Safari iOS 10 | Samsung Internet Android 8.0 |
完整支持
不支持
HTMLTimeElement
interface it belongs to.
HTMLTimeElement
dateTime
BeforeUnloadEvent
DOMStringMap
ErrorEvent
GlobalEventHandlers
HTMLAnchorElement
HTMLAreaElement
HTMLAudioElement
HTMLBRElement
HTMLBaseElement
HTMLBaseFontElement
HTMLBodyElement
HTMLButtonElement
HTMLCanvasElement
HTMLContentElement
HTMLDListElement
HTMLDataElement
HTMLDataListElement
HTMLDialogElement
HTMLDivElement
HTMLDocument
HTMLElement
HTMLEmbedElement
HTMLFieldSetElement
HTMLFormControlsCollection
HTMLFormElement
HTMLFrameSetElement
HTMLHRElement
HTMLHeadElement
HTMLHeadingElement
HTMLHtmlElement
HTMLIFrameElement
HTMLImageElement
HTMLInputElement
HTMLIsIndexElement
HTMLKeygenElement
HTMLLIElement
HTMLLabelElement
HTMLLegendElement
HTMLLinkElement
HTMLMapElement
HTMLMediaElement
HTMLMetaElement
HTMLMeterElement
HTMLModElement
HTMLOListElement
HTMLObjectElement
HTMLOptGroupElement
HTMLOptionElement
HTMLOptionsCollection
HTMLOutputElement
HTMLParagraphElement
HTMLParamElement
HTMLPictureElement
HTMLPreElement
HTMLProgressElement
HTMLQuoteElement
HTMLScriptElement
HTMLSelectElement
HTMLShadowElement
HTMLSourceElement
HTMLSpanElement
HTMLStyleElement
HTMLTableCaptionElement
HTMLTableCellElement
HTMLTableColElement
HTMLTableDataCellElement
HTMLTableElement
HTMLTableHeaderCellElement
HTMLTableRowElement
HTMLTableSectionElement
HTMLTemplateElement
HTMLTextAreaElement
HTMLTitleElement
HTMLTrackElement
HTMLUListElement
HTMLUnknownElement
HTMLVideoElement
HashChangeEvent
历史
ImageData
定位
MessageChannel
MessageEvent
MessagePort
Navigator
NavigatorGeolocation
NavigatorID
NavigatorLanguage
NavigatorOnLine
NavigatorPlugins
PageTransitionEvent
Plugin
PluginArray
PopStateEvent
PortCollection
PromiseRejectionEvent
RadioNodeList
Transferable
ValidityState
Window
WindowBase64
WindowEventHandlers
WindowTimers