//Author: Shantha Kumar T
//Property used: SP.Web.created (sp.js)
//Supports SharePoint 2010 + and SharePoint Online
function getWebCreationDate() {
var clientContext = new SP.ClientContext();
oWeb = clientContext.get_web();
clientContext.load(oWeb);
clientContext.executeQueryAsync(
Function.createDelegate(this, function() {
//The below line returns the created date of website in current locale format
alert(oWeb.get_created());
}),
Function.createDelegate(this, function(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}));
}
function injectMethod() {
getWebCreationDate();
}
ExecuteOrDelayUntilScriptLoaded(injectMethod, "sp.js");This code snippet contains java script code to retrieve the creation date of current web site.
