Retrieve SharePoint Site TimeZone using CSOM

In this post, I’ll be retrieving a SharePoint site’s TimeZone using CSOM.


var context = SP.ClientContext.get_current();
var timeZone = context.get_web().get_regionalSettings().get_timeZone();
context.executeQueryAsync(successHandler, errorHandler);



using (ClientContext ctx = new ClientContext("siteUrl"))
	ctx.Credentials = new SharePointOnlineCredentials("userId", secureStringPassword);
	Microsoft.SharePoint.Client.TimeZone sharePointTimeZone = ctx.Web.RegionalSettings.TimeZone;


The output, in both the cases, will be:
Read More »

Get the UTC DateTime of a SharePoint Field using Client Object Model C#

Following is just a sample to get the current site’s last modified date in UTC. You can apply the same to any DateTime fields in SharePoint. Here, SharePoint itself returns the DateTime in UTC as per its regional setting.
ClientContext ctx = new ClientContext(weburl);
ctx.Credentials = new SharePointOnlineCredentials(userName, passWord); 
RegionalSettings regionalSettings = ctx.Web.RegionalSettings;

ClientResult<DateTime> utcTime = regionalSettings.TimeZone.LocalTimeToUTC(ctx.Web.LastItemModifiedDate);


utcTime.Value is your DateTime in UTC.