Export (0) Print
Expand All

SPTimeZone Class

Windows SharePoint Services 3

Represents the time zone setting that is implemented on a SharePoint Web site.


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

[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public class SPTimeZone

Use the TimeZone property of the SPRegionalSettings class to return the time zone used in a specific site. Otherwise, use the TimeZones property of either the SPRegionalSettings or SPGlobalAdmin class to return the collection of time zones used in the site or in the deployment of Windows SharePoint Services.

Use an indexer to return a single time zone from the collection. For example, if the collection is assigned to a variable named collTimeZones, use collTimeZones[index] in C#, or collTimeZones(index) in Visual Basic, where index is the index number of the time zone in the collection.

The following code example displays the time zone of all sites in the current site collection.

using(SPSite oSiteCollection = new SPSite("http://localhost"))
    SPWebCollection collWebsites = oSiteCollection.AllWebs;
    foreach (SPWeb oWebsite in collWebsites)

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.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions

© 2015 Microsoft