Add Date and Time

There are 2 ways to insert date and time.

Insert date and time using processing instruction

Here is an example in my Docbook file:

<pubdate><?dbtimestamp format="B d, Y at H:M:S"?></pubdate>
<!--Will generate: April 12, 2008 at 16:17:53-->
<!--More on format string can be found at -->

Insert date and time in the customization layer

  1. Add a marker inside your docbook. In my example, I assign my marker now to the role attribute:
    <pubdate role="now"></pubdate>
  2. In my customization layer, I'm using the EXSLT date-time() function supported by xsltprocprocessor. Here is what I put in my customization layer:
    <?xml version="1.0" encoding="UTF-8"?>
      <xsl:stylesheet version="1.0" 
        xmlns:date=""> <!-- This declaration is needed in order to be able to use date and time function. -->
      <!-- Note the xmlns:date="..." above -->
      <xsl:template match="pubdate[@role='now']" mode="titlepage.mode">
        <xsl:variable name="now" select="date:date-time()"/>
          <xsl:text>Generated on </xsl:text>
          <!-- Month name -->
          <xsl:value-of select="date:month-name($now)"/>
          <xsl:text> </xsl:text>
          <!-- Day in month -->
          <xsl:call-template name="TimeDigits">
          <xsl:with-param name="iTime" select="date:day-in-month($now)"/>
          <xsl:text>, </xsl:text>
          <!-- Year -->
          <xsl:value-of select="date:year($now)"/>
          <xsl:text> at </xsl:text>
          <!-- Hour -->
          <xsl:call-template name="TimeDigits">
          <xsl:with-param name="iTime" select="date:hour-in-day($now)"/>
          <!-- Minute -->
          <xsl:call-template name="TimeDigits">
          <xsl:with-param name="iTime" select="date:minute-in-hour($now)"/>
          <!-- Second -->
          <xsl:call-template name="TimeDigits">
          <xsl:with-param name="iTime" select="date:second-in-minute($now)"/>
      <!-- Pad 0 to digit < 10 -->
      <xsl:template name="TimeDigits">
        <xsl:param name="iTime"/>
          <xsl:when test="$iTime &lt; 10"><xsl:value-of select="concat('0',$iTime)"/></xsl:when>
          <xsl:otherwise><xsl:value-of select="$iTime"/></xsl:otherwise>