SPRegionalSettings.TimeZone property

Gets the time zone that is used on the server.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'Declaration
Public Property TimeZone As SPTimeZone
    Get
    Friend Set
'Usage
Dim instance As SPRegionalSettings
Dim value As SPTimeZone

value = instance.TimeZone
public SPTimeZone TimeZone { get; internal set; }

Property value

Type: Microsoft.SharePoint.SPTimeZone
An SPTimeZone object that represents the time zone.

Examples

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.

Dim siteCollection As New SPSite("http://localhost")
Try
    Dim rootWebSite As SPWeb = siteCollection.RootWeb
    Dim regionalsettings As SPRegionalSettings = rootWebSite.RegionalSettings
    Dim IndianaEastTZ As SPTimeZone = regionalsettings.TimeZones(15)
    regionalsettings.TimeZone.ID = IndianaEastTZ.ID

    rootWebSite.Update()
    rootWebSite.Dispose()
Finally
   siteCollection.Dispose()
End Try
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();
    }
}

Note

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 Disposing Objects.

See also

Reference

SPRegionalSettings class

SPRegionalSettings members

Microsoft.SharePoint namespace