Formatting dates in Itemstyle.xsl

Insert this line at the top
xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"

That will give you a header looking like this:

<xsl:stylesheet
  version="1.0"
  exclude-result-prefixes="x d xsl msxsl cmswrt"
  xmlns:x="http://www.w3.org/2001/XMLSchema"
  xmlns:d="http://schemas.microsoft.com/sharepoint/dsp"
  xmlns:cmswrt="http://schemas.microsoft.com/WebParts/v3/Publishing/runtime"
  xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt">

Then use the “ddwrt:FormatDate” to show the date i various ways:

<xsl:value-of select="ddwrt:FormatDate(@dato, 1030, 3)"/>
<xsl:value-of select="ddwrt:FormatDateTime(string(@Publiceret), 1030, 'dd. MMM. yyyy')"/>
<xsl:value-of select="ddwrt:FormatDate(string(@Dato), 1033, 7) "/>

List of all LCID’s : http://support.microsoft.com/default.aspx?id=221435
Custom date and time formats: http://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx

Formatflags
dateflags

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.