SPWeb.Created property

Gets or sets a date and time value that indicates when the site was created. (Read-only in sandboxed solutions.)

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

'Declaration
Public Property Created As DateTime
	Get
	Set
'Usage
Dim instance As SPWeb
Dim value As DateTime

value = instance.Created

instance.Created = value

Property value

Type: System.DateTime
A System.DateTime object that indicates when the site was created, specified in Coordinated Universal Time (UTC) format and not in system time or time zone settings in Microsoft SharePoint Foundation.

The Created property applies only to sites that are returned by using one of the GetSubwebsForCurrentUser methods of the SPWeb class. It returns an SPException object if it is applied to a site collection that is not obtained by using one of these methods.

The following code example displays the name and creation date of each subsite within a specified site collection of which the current user is a member.

This example requires using directives (Imports in Microsoft Visual Basic) for the Microsoft.SharePoint namespace and the Microsoft.SharePoint.Utilities namespace.

Dim siteCollection As New SPSite("http://Server_Name/sites/Site_Name")
Dim webSites As SPWebCollection = siteCollection.OpenWeb().GetSubwebsForCurrentUser()

For i  As  Integer = 0 To webSites.Count - 1
    Response.Write((SPEncode.HtmlEncode(webSites(i).Name) + " :: " + webSites(i).Created.ToString() + "<BR>"))

    webSites(i).Dispose()
Next
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 Disposing Objects.

Show: