HTMLTimeElement.dateTime - Web APIs 编辑

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:

MicrosyntaxDescriptionExamples
Valid month stringYYYY-MM2011-11, 2013-05
Valid date stringYYYY-MM-DD1887-12-01
Valid yearless date stringMM-DD11-12
Valid time stringHH:MM
HH:MM:SS
HH:MM:SS.mmm
23:59
12:15:47
12:15:52.998
Valid local date and time stringYYYY-MM-DD HH:MM
YYYY-MM-DD HH:MM:SS
YYYY-MM-DD HH:MM:SS.mmm
YYYY-MM-DDTHH:MM
YYYY-MM-DDTHH:MM:SS
YYYY-MM-DDTHH:MM:SS.mmm
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 stringZ
+HHMM
+HH
:MM
-HHMM
-HH
:MM
Z
+0200
+04:30
-0300
-08:00
Valid global date and time stringAny combination of a valid local date and time string followed by a valid time-zone offset string2013-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 stringYYYY-WWW2013-W46
Four or more ASCII digitsYYYY2013, 0001
Valid duration stringPdDThHmMsS
PdDThHmMs.XS
PdDThHmMs.XXS
PdDThHmMs.XXXS
PThHmMsS
PThHmMs.XS
PThHmMs.XXS
PThHmMs.XXXS
wwddhhmmss
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

SpecificationStatusComment
HTML Living Standard
The definition of 'HTMLTimeElement' in that specification.
Living StandardNo change from HTML 5.1.
HTML 5.1
The definition of 'HTMLTimeElement' in that specification.
RecommendationNo change from HTML5.
HTML5
The definition of 'HTMLTimeElement' in that specification.
RecommendationInitial definition.

Browser compatibility

BCD tables only load in the browser

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:71 次

字数:7381

最后编辑:6 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文