XSLT Function FormatDate

Formats the date using a pattern.

NAMESPACE

xmlns:AS="http://schema.advantages.cz/AsapFunctions"

SYNTAX

string FormatDate(string date, string format)

PARAMETERS

Name Description
date Date to be formatted.
format Formatting pattern. See .NET Custom Format Strings for available patterns.

REMARKS

Formatting is always done using the logged-in user’s locale.

EXAMPLE

This example formats a date for US English style.
Source XML

<ROOT> 
    <test date="2012-03-23"/> 
</ROOT>

Stylesheet

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" 
    xmlns:AS="http://schema.advantages.cz/AsapFunctions" 
    xmlns:date="http://exslt.org/dates-and-times" exclude-result-prefixes="AS date"> 
    <xsl:template match="/"> 
        <test test="{concat('The date is ', AS:FormatDate(/ROOT/test/@date, 'MM\/dd\/yyyy'))}"/> 
    </xsl:template> 
</xsl:stylesheet>