XSLT 2
Date functions are available natively, such as:
<xsl:value-of select="current-dateTime()"/>
There is also current-date()
and current-time()
.
XSLT 1
Use the EXSLT date and times extension package.
- Download the date and times package from GitHub.
- Extract
date.xsl
to the location of your XSL files. - Set the stylesheet header.
- Import
date.xsl
.
For example:
<xsl:stylesheet version="1.0"
xmlns:date="http://exslt.org/dates-and-times"
extension-element-prefixes="date"
...>
<xsl:import href="https://stackoverflow.com/questions/1575111/date.xsl" />
<xsl:template match="//root">
<xsl:value-of select="date:date-time()"/>
</xsl:template>
</xsl:stylesheet>