This topic has not yet been rated - Rate this topic

SPRegionalSettings.TimeZone Property

Windows SharePoint Services 3
Gets the time zone that is used on the server.

Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in microsoft.sharepoint.dll)
public SPTimeZone TimeZone { get; }

Property Value

An SPTimeZone object that represents the time zone.

The following code example returns the Indiana time zone through the TimeZones property and then assigns the time zone to the root Web site of the specified site collection.

using (SPSite oSiteCollection = new SPSite("http://localhost"))
{
    using(SPWeb oWebsiteRoot = oSiteCollection.RootWeb)
    { 
        SPRegionalSettings oRegionalSettings = oWebsiteRoot.RegionalSettings; 
        SPTimeZone oTimeZoneIndianaEast = oRegionalSettings.TimeZones[15]; 
        oRegionalSettings.TimeZone.ID = oTimeZoneIndianaEast.ID; 
        oWebsiteRoot.Update();
    }
}
NoteNote:

Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Best Practices: Using Disposable Windows SharePoint Services Objects.

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ