SPRegionalSettings.TimeZone 属性

获取服务器上使用的时区。

命名空间:  Microsoft.SharePoint
程序集:  Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)

语法

声明
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; }

属性值

类型:Microsoft.SharePoint.SPTimeZone
一个代表时区的SPTimeZone对象。

示例

下面的代码示例返回印地安那州所在的时区通过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 类

SPRegionalSettings 成员

Microsoft.SharePoint 命名空间