<time> datetime 属性的使用方法,datetime属性表示 <time>元素的机器可读日期/时间。
具有机器可读的datetime属性的time元素:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>菜鸟教程(cainiaojc.com)</title> </head> <body> <p>我们在<time datetime="2019-12-25">圣诞节</time>举办一个Party。</p> </body> </html>测试看看 ‹/›
IEFirefoxOperaChromeSafari
datetime 属性在所有浏览器中不会渲染任何特殊的效果。
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 -->
<time> 标签是 HTML5 新标签。
<time datetime="YYYY-MM-DDThh:mm:ssTZD">
值 | 描述 |
---|---|
YYYY-MM-DDThh:mm:ssTZD | 日期或时间。下面解释了其中的成分:
|