Date and time

The stylesheets have a feature to generate date and time strings. These can be used to insert the processing date for display or for meta data. These features make use of the EXSLT date-time() function. That function is supported by the Saxon, Xalan, and xsltproc processors, but not MSXSL.

There is no DocBook element that represents the current date, so the stylesheets use a processing instruction to insert a timestamp. Here is an example:

<para>This document was generated 
<?dbtimestamp format="Y-m-d H:M:S"?>.</para>

When processed, this input will result in the following output in either HTML or print:

This document was generated 2003-07-23 12:13:00.

The dbtimestamp processing instruction name triggers the date functions, and the format string is used to select and format the components of date and time. The component letters are as follows:

Date-time format letterExampleDescription
aThuDay abbreviation
AThursdayDay name
bJulMonth abbreviation
c2003-07-10-07:00 12:20:33-07:00Complete ISO date and time, including offset from UTC.
BJulyMonth name
d10Day in month
H11Hour in day
j191Day in year
m07Month in year
M20Minute in hour
S14Second in minute
U28Week in year
w5Day in week (Sunday = 1)
x2003-07-10-07:00ISO date
X12:20:33-07:00ISO time
Y2003Year.

Any other characters in the format string are passed through, allowing you to add punctuation as needed.

You can also use the date functions more directly in a customization layer. See the section “Adding a date timestamp” for an example.