HTMLTimeElement:dateTime 属性

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since October 2017.

HTMLTimeElement.dateTime 属性是一个反映 datetime HTML 属性的字符串,包含元素日期和时间值的机器可读形式。

一个字符串。对于有效的字符串格式,请参见 datetime 有效值

示例

js
// 假设 HTML 中有 <time id="t"> 元素
const t = document.getElementById("t");
t.dateTime = "6w 5h 34m 5s";

规范

Specification
HTML
# dom-time-datetime

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
dateTime

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Has more compatibility info.

参见