导航
×
   ❮   
HTML CSS JavaScript PHP Go Sass W3C Colors ECMS

HTML 参考手册

HTML 元素(功能排序) HTML 浏览器支持 HTML 属性 HTML 全局属性 HTML 事件 HTML 颜色 HTML 画布 HTML 音频/视频 HTML 字符集 HTML 文档类型 HTML URL 编码 HTML 语言代码 HTML 国家代码 HTTP 状态消息 HTTP 请求方法 PX-EM 转换 键盘快捷键

HTML 标签

<!--> <!DOCTYPE> <a> <abbr> <acronym> <address> <applet> <area> <article> <aside> <audio> <b> <base> <basefont> <bdi> <bdo> <big> <blockquote> <body> <br> <button> <canvas> <caption> <center> <cite> <code> <col> <colgroup> <data> <datalist> <dd> <del> <details> <dfn> <dialog> <dir> <div> <dl> <dt> <em> <embed> <fieldset> <figcaption> <figure> <font> <footer> <form> <frame> <frameset> <h1> - <h6> <head> <header> <hr> <html> <i> <iframe> <img> <input> <ins> <kbd> <label> <legend> <li> <link> <main> <map> <mark> <meta> <meter> <nav> <noframes> <noscript> <object> <ol> <optgroup> <option> <output> <p> <param> <picture> <pre> <progress> <q> <rp> <rt> <ruby> <s> <samp> <script> <section> <select> <small> <source> <span> <strike> <strong> <style> <sub> <summary> <sup> <svg> <table> <tbody> <td> <template> <textarea> <tfoot> <th> <thead> <time> <title> <tr> <track> <tt> <u> <ul> <var> <video> <wbr>

HTML <time> datetime 属性


实例

具有机器可读日期时间属性的 time 元素:

<p>I have a date on<time datetime="2017-02-14">Valentines day</time>.</p>
亲自试一试 »

定义和用法

datetime 属性规定日期或时间。在 time 元素的内容中未指定日期或时间时,使用该属性。

有效日期时间值的示例:

Dates:
<time datetime="1914">  <!-- means the year 1914 -->
<time datetime="1914-12">  <!-- means December 1914 -->
<time datetime="1914-12-20">  <!-- means 20 December 1914 -->
<time datetime="12-20">  <!-- means 20 December any year -->
<time datetime="1914-W15">  <!-- means week 15 of year 1914 -->
Date and Times:
<time datetime="1914-12-20T08:00">  <!-- means 20 December 1914 at 8am -->
<time datetime="1914-12-20  08:00"> <!-- also means 20 December 1914 at 8am -->
<time datetime="1914-12-20  08:30:45"> <!-- with minutes and seconds -->
<time datetime="1914-12-20  08:30:45.687"> <!-- with minutes, seconds, and  milliseconds -->
Times:
<time datetime="08:00">  <!-- means 8am -->
<time datetime="08:00-03:00">  <!-- means 8am in Rio de Janeiro (UTC-3 hours)  -->
<time datetime="08:00+03:00">  <!-- means 8am in Madagascar (UTC+3 hours)  -->
Durations:
<time datetime="P2D"> <!--  means a duration of 2 days -->
<time datetime="PT15H10M">  <!-- means a duration of 15 hours and 10 minutes -->

浏览器支持

属性          
datetime 62.0  18.0 22.0 7.0 49.0

语法

<time datetime="YYYY-MM-DDThh:mm:ssTZD">

属性值

描述
YYYY-MM-DDThh:mm:ssTZD

或者

PTDHMS
指定的日期或时间。各部分说明
  • YYYY - 年(例如 2011)
  • MM - 月(例如 01 表示一月)
  • DD - 月中的某一天(例如 08)
  • T 或空格 - 分隔符(如果也指定了时间,则必需)
  • hh - 小时(例如 22 表示晚上 10 点)
  • mm - 分钟(例如 55)
  • ss - 秒(例如 03)
  • TZD - 时区标识符(Z 表示 Zulu,也称为格林威治标准时间)
  • P - "Period"(期间)的前缀
  • D - "Days"(天)的前缀
  • H - "Hours"(小时)的前缀
  • M - "Minutes"(分钟)的前缀
  • S - "Seconds"(秒)的前缀

Copyright ©2020-2026 freew3c.com All Rights Reserved 提供的内容仅用于学习和测试,不保证内容的正确性。