I recently had to apply a change to a SharePoint site that would alter the display format of the date – but without changing the culture and region of the site as it was now configured. The client was requesting to display the date in yyyy/MM/dd format and this date format matched a few countries in Africa and Japan, but we would not want to change the region to foreign countries because then you have currency issues.

I came across a site at http://dotnet.lv/blogs/antonsm/archive/2008/12/21/change-date-format-in-sharepoint.aspx that detailed how to do this. He details the process and issues met with his method and we tried to use this to resolve our issue but ended up with a site that was set to a Japan locale that was displaying everything fine but the LCID would be saved as if the site was in Japan.

I assigned this task to a developer at the office, Aftab Shaikh, and together we came up with the following modified code to apply the change in date format display while retaining the locale and region.

The following code can be added to a console app/windows forms app:

using Microsoft.SharePoint;
using System.Globalization;

try
{
    CultureAndRegionInfoBuilder.Unregister("en-US");
}
catch { }

CultureAndRegionInfoBuilder carib = new CultureAndRegionInfoBuilder("en-US", CultureAndRegionModifiers.Replacement);
carib.LoadDataFromCultureInfo(new CultureInfo("en-US"));
carib.LoadDataFromRegionInfo(new RegionInfo("en-US"));
carib.GregorianDateTimeFormat.ShortDatePattern = "yyyy/MM/dd";
carib.Register();  

CultureInfo ci = new CultureInfo("en-US");

string siteUrl = string.Empty;
Console.WriteLine("Enter site url:");
siteUrl = Console.ReadLine();

using(SPSite site = new SPSite(siteUrl))
{
    using(SPWeb web = site.RootWeb)
    {
        web.Locale = ci;
        web.Update();
    }
}

Console.WriteLine("Done");
Console.ReadLine();

To compile, you will need to add a reference to the sysglobl (sysglobl.dll) assembly.

After running this code, your site will remain as en-US in this case and will display the date in the format defined.

Note: The site I reference in this post seems to be offline so here is a xps version of the site before it went offline: download