SharePoint Config

Ari Bakker's thoughts on customising and configuring SharePoint 2007 and 2010

Date Formats in SharePoint

without comments

To ensure that dates are formatted correctly across your WSS or MOSS site there are a couple of settings you may need to change.

First of all the regional settings should reflect the current locale. This can be changed from Site Actions > Site Settings > Regional Settings and ensuring the locale is correct. This should ensure all controls that display dates are formatted correctly.

If you are using XSLT to display dates (such as in a data view web part) you may need to update these also. One way of doing this is to take advantage of the format-date extension function provided by MSXML. This is included in the XSL for the dataview by default, but you can use this and other MSXML extension functions by including a reference to the Microsoft XPath extension functions (urn:schemas-microsoft-com:xslt) at the top of your XSL stylesheet i.e.

<xsl:stylesheet ... xmlns:msxsl="urn:schemas-microsoft-com:xslt">

You can then use the format-date (and format-time) functions like so:

<xsl:value-of select="msxsl:format-date(@_DCDateCreated, 'dd/MM/yyy')"/>

This will format the date in the form 30/03/2007. The Microsoft XPath extension functions page contains a full list of formatting characters.

Note: you can also take advantage of the format-date function in other .NET applications that use xsl transforms.

Post to Twitter Post to Delicious Post to Digg Post to Reddit Post to StumbleUpon

Written by Ari Bakker

April 2nd, 2007 at 3:27 am

Leave a Reply