此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

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 ⁨2017年10月⁩.

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

浏览器兼容性

参见