Example

Time Date Markup in HTML

HTML

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Time Date Markup in HTML</title>
</head>
<body>
<!--
    <time> : used for marking up times & dates in machine-readable format.
    datetime : attribute indicates the time and/or date of the element    
-->

    <h1>Demo: Time Date Markup in HTML</h1>     

    <!-- Standard simple date -->
    <time datetime="2022-01-20">20 January 2022</time> <br><br>

    <!-- Just year and month -->
    <time datetime="2022-01">January 2022</time> <br><br>

    <!-- Just month and day -->
    <time datetime="01-20">20 January</time> <br><br>

    <!-- Just time, hours and minutes -->
    <time datetime="19:30">19:30</time> <br><br>

    <!-- You can do seconds and milliseconds too -->
    <time datetime="19:30:01.856">19:30:01.856</time> <br><br>

    <!-- Date and time -->
    <time datetime="2022-01-20T19:30">7.30pm, 20 January 2022</time> <br><br>

    <!-- Date and time with timezone offset -->
    <time datetime="2022-01-20T19:30+01:00">7.30pm, 20 January 2022 is 8.30pm in France</time> <br><br>
    
    <!-- Calling out a specific week number -->
    <time datetime="2022-W04">The fourth week of 2022</time> <br><br>

</body>
</html>

Output

View original