Previous | Next | Indexes
Zvon > Tutorials > XSLT 2.0 Tutorial > Date and Time (1/7) >

Finding current date and time

Current date and time can be get by calling functions current-dateTime(), current-date(), and current-time().
XSLT

      <xsl:stylesheet
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                  version="2.0">
            <xsl:output  method="xml"
                        indent="yes"
                        omit-xml-declaration="yes"/>

            <xsl:template  match="/aaa">
                  <xxx>
                        <xsl:value-of  select="current-dateTime()"/>
                  </xxx>
                  <yyy>
                        <xsl:value-of  select="current-date()"/>
                  </yyy>
                  <zzz>
                        <xsl:value-of  select="current-time()"/>
                  </zzz>
            </xsl:template>

      </xsl:stylesheet>
XML

      <aaa/>
Output

      <xxx>2005-12-13T14:13:28.443+01:00</xxx>
      <yyy>2005-12-13+01:00</yyy>
      <zzz>14:13:28.443+01:00</zzz>


Previous chapter: Recursions
Next chapter: Comments and processing instructions
Previous page: - - -
Next page: Extracting day, month, and year from date