共用方式為


SPRegionalSettings.TimeZone property

取得伺服器使用的時區。

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

Syntax

'宣告
Public Property TimeZone As SPTimeZone
    Get
    Friend Set
'用途
Dim instance As SPRegionalSettings
Dim value As SPTimeZone

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

Property value

Type: Microsoft.SharePoint.SPTimeZone
代表時區SPTimeZone物件。

Examples

下列程式碼範例會傳回印地安那時區透過TimeZones屬性,並再將時區指派給指定的網站集合的根網站。

Dim siteCollection As New SPSite("https://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("https://localhost"))
{
    using(SPWeb oWebsiteRoot = oSiteCollection.RootWeb)
    { 
        SPRegionalSettings oRegionalSettings = oWebsiteRoot.RegionalSettings; 
        SPTimeZone oTimeZoneIndianaEast = oRegionalSettings.TimeZones[15]; 
        oRegionalSettings.TimeZone.ID = oTimeZoneIndianaEast.ID; 
        oWebsiteRoot.Update();
    }
}
注意事項注意事項

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.

請參閱

參照

SPRegionalSettings class

SPRegionalSettings members

Microsoft.SharePoint namespace