Section outline

    • Indicating Dates and Time

      Another semantic inline element, time , was introduced by HTML5 to indicate content that is a date, time, or both. For example,


      <p>Today it is <time>2009-07-08</time> which is an interesting date.</p>

      as well as


      <p>An interesting date/time for SciFi buffs is <time>1999-09-13T09:15:00</time>!</p>

      would both be valid. The element should contain a date/time value that is in the format YYYY-MM-DDThh:mm:ssTZD , where the letters correspond to years, months, days, hours, minutes, and seconds, T} is the actual letter ‘T,’ and ZD} represents a time zone designator of either Z  or a value like +hh:mm  to indicate a time zone offset. However, it seems reasonable that the time} element would contain values that may not be in a common format but are recognized by humans as dates. If you try something like


      <p>Right now it is <time>6:15</time>.</p>

      it may be meaningful to you but it does not conform to HTML5. To provide both human- and machine-friendly date/time content, the element supports a datetime} attribute, which should be set to the previously mentioned date format of YYYY-MM-DDThh:mm:ssTZD}. So, the following example is meaningful because it provides both a readable form and a machine-understood value:


      <p>My first son was born on <time datetime="2018-01-13">Friday the 13th</time> so it is my new lucky day.</p>