Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

1. Fundamental Syntax and Semantics > 1.16. Marking Up Dates and Times

1.16. Marking Up Dates and Times

Problem

You want to encode date-time content for machines, but still retain human readability.

Solution

Wrap the human-friendly date-time information in the time element, and specify the machine-readable information via the datetime attribute:

<p>Published: <time datetime="2011-01-15">January 15, 2011</time></p>

Depending on the date and time you are trying to specify, the following approaches are also valid:

Time only
<p>The class starts at <time datetime="08:00">8:00 am</time>.</p>
Date and time (requires time zone specification)
<p>Registration opens on <time datetime="2011-01-15T08:00-07:00">January 15, 2011
   at 8:00 am, Mountain Time</time>.</p>
Visible machine-readable format (no date-time required)

  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial