XSLT date time processing


/ Published in: XSLT
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <xsl:template name="formatDate">
  2. <xsl:param name="dateTime" />
  3. <xsl:variable name="date" select="substring-before($dateTime, 'T')" />
  4. <xsl:variable name="year" select="substring-before($date, '-')" />
  5. <xsl:variable name="month" select="substring-before(substring-after($date, '-'), '-')" />
  6. <xsl:variable name="day" select="substring-after(substring-after($date, '-'), '-')" />
  7. <xsl:value-of select="concat($day, ' ', $month, ' ', $year)" />
  8. </xsl:template>
  9.  
  10. <xsl:template name="formatTime">
  11. <xsl:param name="dateTime" />
  12. <xsl:value-of select="substring-after($dateTime, 'T')" />
  13. </xsl:template>
  14.  
  15.  
  16. <xsl:call-template name="formatDate">
  17. <xsl:with-param name="dateTime" select="xpath" />
  18. </xsl:call-template>
  19.  
  20. <xsl:call-template name="formatTime">
  21. <xsl:with-param name="dateTime" select="xpath" />
  22. </xsl:call-template>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.