Search code examples
xslttridion

How to get current date and time in XSLT 1.0


I am using xslt 1.0, I am trying to print current date and time to my node. Below is the sample xslt

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:tcm="http://www.tridion.com/ContentManager/5.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:em="http://www.emirates.com/tridion/schemas" xmlns:tcmse="http://www.tridion.com/ContentManager/5.1/TcmScriptAssistant" exclude-result-prefixes="em xlink tcmse tcm">
  <xsl:output method="xml" version="1.0" encoding="UTF-16" indent="yes"/>

  <!-- Common XSLT Templates-->
  <xsl:include href="tcm:228-190524-2048"/>
  <!-- root match-->
  <xsl:template match="root">
    <sitedata>
      <resources>        
        <PublishedDate>
          <xsl:value-of select="$publishedDate"/>
        </PublishedDate>
      </resources>     
    </sitedata>
  </xsl:template>

In above XSLT, in the place of $publishedDate I want system current date and time

please suggest!!


Solution

  • XSLT 1.0 does not provide any standard way to get the current date/time. You can call an extension function to do it (depends on your processor), or you can pass it to the stylesheet as the value of a parameter.