DateTime format in Xslt

09/01/2013 14:08

Format Date in Xslt

1. Add ddwrt namespace to xslt file header

xmlns:ddwrt="https://schemas.microsoft.com/WebParts/v2/DataView/runtime"

 

2. Use ddwrt functions

 <xsl:value-of select="ddwrt:FormatDateTime(@Created, 1033, 'd MMMM yyyy')" />

for 14 january 2012

or

<xsl:value-of select="ddwrt:FormatDateTime(@Created, 1043, 'd MMMM yyyy a\t HH:mm')" />

for 14 january 2012 at 12:21 (t is special character and has to be escaped - or divide it to:

<xsl:value-of select="ddwrt:FormatDateTime(@Created, $Lcid, 'd MMMM yyyy')" />
    at <xsl:value-of select="ddwrt:FormatDateTime(@Created, $Lcid, 'HH:mm')" />

where $lcid = 1033 or other.