目次
Examples to Implement HTML Time Tag
Example #1 – using a <time> tag.
Example #2
Example #3 – Using Css.
Example #4 – Using pubdate attribute.
Conclusion

HTML 時間タグ

Sep 04, 2024 pm 04:30 PM
html html5 HTML Tutorial HTML Properties HTML tags

ご存知のとおり、HTML は Web 開発分野で進化し続けており、世界中で人気のあるマークアップ言語です。 Web 開発者は HTML 要素を更新し、学習する必要があると言われています。この記事では、タイムタグと呼ばれるいくつかの重要なタグについて学びます。人間にとっては、さまざまな形式の日付/時刻を読み取るのは簡単ですが、機械の場合、その時刻までに解析するのは簡単ではありません。今回は、タグは特定の期間を定義し、特定の Web ページの日付と時刻を指定します。したがって、これらは非常に便利であり、人間が読めるタグを表します。この人間が読める形式は、インターネット プロトコルの貴重な形式です。 タグは HTML 5 ではサポートされていますが、HTML 4.01 バージョンではサポートされていません。

時間は次の方法で定義できます:

  • 期間
  • 24 時間制の正しい時刻
  • グレゴリオ暦の日付

時間の進行の利点により、Web ページはより構造化され、検索エンジンが HTML コードを簡単に読み取って Web ページ上のアイデアを分析できるようになり、イベントのスケジュール設定や時間関連のイベント機能の開発に役立ちます。たとえば、検索エンジンでは現在のイベントと関連付けられており、視覚的な時間イベントによって現在の Web ページを上位にランク付けするのに役立ちます。

構文:

<time> 2020-01-28 </time>
ログイン後にコピー

基本的な日付/時刻属性を使用すると、コンピューター向けの特定の形式で一意の時刻タグが得られます。

上記の構文から、

であると言われています。タグには、時刻、日付の両方、または両方を一緒に保持します。想定される形式は、最大期間から下位期間の年 – 月 – 日 hh: mm: ss タイム ゾーンで指定されます。 Date Time 属性がない場合は、この形式が使用されます。

属性

属性は HTML において重要な役割を果たします。この HTML 要素を使用すると、ユーザーは仕事のスケジュールの日付や誕生日のリマインダーをそれぞれのカレンダーに柔軟に追加できます。もう 1 つの利点は、検索エンジンがより良い検索結果を提供できることです。この time 要素は、グローバル属性とイベント属性をサポートします。それとは別に、重要な属性は日付時刻です。 「月曜日」のような値を表示するには、「金曜日」の日時属性を表します。

以下の表は、この要素に関連する属性とその説明を示しています。
Attribute Name Description
DateTime It specifies a machine-readable input time of the element.
Pubdate It has a Boolean value that Specifies the publication date of the content.
属性名 説明 日付時刻 機械可読な要素の入力時間を指定します。 発行 コンテンツの発行日を指定するブール値があります。 テーブル>

There are some different ways of representing the date-time attribute. The profile of ISO 8601 provides the standards which follow the ABNF notation. And the letters below ‘T’ and ‘Z’ should be declared in the Upper case.

1. Year and Month

Very Simple Format with the year before.

2019 – 08

2. Date Alone

1946-08-17

3. Date without Year

08-21

4. Only Time Display

13: 55: 30. 522

5. Date and Time

2014 – 08 -21T15:55

Here T is for separation between Date and Time.

6. Time Zone Format

It initiates with either plus or minus and, in some cases, ( : ) is replaced With the capital ‘Z’.

+ 08 : 05

7. Year and Week

Follow the corresponding number of weeks after the letter ‘W’ to represent a week.

2017 – W 20

8. Duration (with Two methods)

2w 3d 4 h 25 min 12.402s

Also, it supports global attribute along with this element like id, class, style and supporting event attributes like onabort, onfocus, onclick, onmousedown, onmouseout, onkeyup, onchange, ondrag, ondrop, onselect, onmessage, onscroll.

Examples to Implement HTML Time Tag

Using this tag, You can display the date or time without a datetime attribute. The following are some examples:

Example #1 – using a

Code:

<!DOCTYPE html>
<html>
<head>
<title>
HTML Time Tag
</title>
</head>
<body style="text-align:left;">
<h2>HTML Time Tag demo</h2>
<p> India celebrate as
<time>2020-01-26</time> Republic day
</p>
</body>
</html>
ログイン後にコピー

Output:

HTML 時間タグ

Example #2

Making a time element to the title attribute to show detailed information about the user in a nice human-readable or machine-readable format.

Code:

<!DOCTYPE html>
<html>
<body>
<h2> <center> Date Time Example </center> </h2>
<h3>The Stand- Up Comedy show starts at <time datetime="2018-07-04T20:00:00Z">20:00</time> coming Saturday.</h3>
<h3>The preview show starts in <time datetime="PT3H0M3S">5h 1m 0s</time>.</h3>
</body>
</html>
ログイン後にコピー

In the below Output, the time tag instructs the browser about the text used between the attribute is a time reference ( 5 h 1m 0s) but doesn’t display the time attribute.

Output:

HTML 時間タグ

Example #3 – Using Css.

Code:

<!doctype html>
<html>
<body>
<article>
<body style="background-color:yellow;">
<h1>Title of the document</h1>
<p>Introduction to the Article</p>
</article>
<footer>
<p>This content is published on <time>2016-1-20</time>.</p>
<p>Our shop opens at <time>08:00</time>.</p>
</footer>
</body>
</html>
ログイン後にコピー

Output: 

HTML 時間タグ

Example #4 – Using pubdate attribute.

Code:

<!DOCTYPE html>
<html>
<body>
<article>
<h1>A good Article</h1>
<p>Introduction on a given Article.</p>
<footer>
<p>Content published on <time datetime="2019-02-04" pubdate>February the 4th, 2019</time>
</footer>
</article>
</body>
</html>
ログイン後にコピー

Output:

HTML 時間タグ

Conclusion

Therefore, we learned how to work with the

以上がHTML 時間タグの詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。

ホットAIツール

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

Video Face Swap

Video Face Swap

完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

ホットツール

メモ帳++7.3.1

メモ帳++7.3.1

使いやすく無料のコードエディター

SublimeText3 中国語版

SublimeText3 中国語版

中国語版、とても使いやすい

ゼンドスタジオ 13.0.1

ゼンドスタジオ 13.0.1

強力な PHP 統合開発環境

ドリームウィーバー CS6

ドリームウィーバー CS6

ビジュアル Web 開発ツール

SublimeText3 Mac版

SublimeText3 Mac版

神レベルのコード編集ソフト(SublimeText3)

HTMLの表の境界線 HTMLの表の境界線 Sep 04, 2024 pm 04:49 PM

HTML の表の境界線に関するガイド。ここでは、HTML でのテーブルの境界線の例を示しながら、テーブル境界線を定義する複数の方法について説明します。

HTML のネストされたテーブル HTML のネストされたテーブル Sep 04, 2024 pm 04:49 PM

これは、HTML でのネストされたテーブルのガイドです。ここでは、テーブル内にテーブルを作成する方法をそれぞれの例とともに説明します。

HTML 左マージン HTML 左マージン Sep 04, 2024 pm 04:48 PM

HTML マージン左のガイド。ここでは、HTML margin-left の概要とその例、およびそのコード実装について説明します。

HTML テーブルのレイアウト HTML テーブルのレイアウト Sep 04, 2024 pm 04:54 PM

HTML テーブル レイアウトのガイド。ここでは、HTML テーブル レイアウトの値と例および出力について詳しく説明します。

HTML入力プレースホルダー HTML入力プレースホルダー Sep 04, 2024 pm 04:54 PM

HTML 入力プレースホルダーのガイド。ここでは、コードと出力とともに HTML 入力プレースホルダーの例について説明します。

PHPでHTML/XMLを解析および処理するにはどうすればよいですか? PHPでHTML/XMLを解析および処理するにはどうすればよいですか? Feb 07, 2025 am 11:57 AM

このチュートリアルでは、PHPを使用してXMLドキュメントを効率的に処理する方法を示しています。 XML(拡張可能なマークアップ言語)は、人間の読みやすさとマシン解析の両方に合わせて設計された多用途のテキストベースのマークアップ言語です。一般的にデータストレージに使用されます

HTML 順序付きリスト HTML 順序付きリスト Sep 04, 2024 pm 04:43 PM

HTML 順序付きリストのガイド。ここでは、HTML 順序付きリストと型の導入とその例についても説明します。

HTML の onclick ボタン HTML の onclick ボタン Sep 04, 2024 pm 04:49 PM

HTML オンクリック ボタンのガイド。ここでは、それらの紹介、動作、例、およびさまざまなイベントでの onclick イベントについてそれぞれ説明します。

See all articles