Open In App

How to display the time in HTML ?

Last Updated : 30 Jan, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

The <time> Tag is used to display the human-readable date/time. It can also be used to encode dates and times in a machine-readable form. The main advantage for users is that they can offer to add birthday reminders or scheduled events to their calendars and search engines can produce smarter search results.

  • <time> is used to represent specific dates and times.
  • Utilize the datetime attribute for a machine-readable format.
  • Include human-readable content within the `<time>` tags.
  • Adds semantic meaning to time-related content.
  • Improves accessibility with both machine-readable and human-readable representations.

Syntax

<time attribute> Time... </time>

Example:

HTML




<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content=
          "width=device-width, initial-scale=1.0">
    <title>Time Element</title>
</head>
 
<body>
    <p>Published on
      <time datetime="2024-01-31">January 31, 2024</time>
      </p>
</body>
 
</html>


Output:

Screenshot-2024-01-24-170136


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads