SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can we set the locale of a sharepoint site for a particular user according to his/her system locale through coding?

Edit: Specifically, I've created a list through coding. Suppose that I've added an item to that list. Then I've changed the locale. Then again when I'm trying to add another item within than list it throws an exception regarding the date format as it has already been changed.

share|improve this question
up vote 0 down vote accepted


 using (SPSite site = new SPSite("http://sp"))
        using (SPWeb web = site.RootWeb)
            if (web != null)
                web.AllowUnsafeUpdates = true;
                CultureInfo culture = new CultureInfo("en-US");
                if (culture != null)
                    web.Locale = culture;
                web.AllowUnsafeUpdates = false;
    catch (Exception ex)
        // Log exception
share|improve this answer

The general Regional Settings you can set via the SPWeb object: SPWeb.Locale. The per user setting is stored with the SPUser object, specifically SPuser.RegionalSettings like explained here.

Edit: You can get the locale of the current user by getting the current SPUser via SPWeb.CurrentUser, then again you can get the RegionalSettings from this user.

I'm not sure how you can get the system locale of the current user via code behind stuff - it would be possible via Javascript and make changes based on that.

share|improve this answer
Thanks a lot Moontear.But the problem is that I wanna set the site locale according to the system locale of the user automatically. – DeathRider Dec 21 '11 at 14:42
Suppose my system locale is set to en-GB.Then I need that when I'll be opening the sharepoint site the site locale will be dinamically set to en-GB. – DeathRider Dec 21 '11 at 14:45
Typically you can get the current culture in .Net using this - Thread.CurrentThread.CurrentCulture. However since your code runs in SharePoint context, I guess you may get the web's locale only but you can give it a shot and see if it returns what you are looking for. – Nitin Rastogi Dec 21 '11 at 15:15

Depending on your requirements will depend on which language you use and how you implement this.

You can update the regional settings for a web site using PowerShell by using SPWeb.Locale property. This could be used by a script which configures new sites automatically.

This site describes SPWeb.Locale:

This site demonstrates updating the regional settings using a simple PowerShell script:


I only just read the tag with sharepoint-online. Currently PowerShell can't be used remotely for SP online. There is plenty of discussion about if/when this will occur. You can, however, use web services to administer the site. You can connect via Web Services to PowerShell using the New-WebServiceProxy cmdlet.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.