Retrieve SharePoint Site TimeZone using CSOM

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

JS

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

 

C#

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

	ctx.Load(sharePointTimeZone);
	ctx.ExecuteQuery();
}

The output, in both the cases, will be:

  • Id => 13
  • Description => (UTC-08:00) Pacific Time (US and Canada)

Id, here is the true identifier. Here’s a list of Ids that are used in a SharePoint farm.

ID Time Zone
2 (GMT) Greenwich Mean Time : Dublin, Edinburgh, Lisbon, London
3 (GMT+01:00) Brussels, Copenhagen, Madrid, Paris
4 (GMT+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna
5 (GMT+02:00) Athens, Bucharest, Istanbul
6 (GMT+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague
7 (GMT+02:00) Minsk
8 (GMT-03:00) Brasilia
9 (GMT-04:00) Atlantic Time (Canada)
10 (GMT-05:00) Eastern Time (US and Canada)
11 (GMT-06:00) Central Time (US and Canada)
12 (GMT-07:00) Mountain Time (US and Canada)
13 (GMT-08:00) Pacific Time (US and Canada)
14 (GMT-09:00) Alaska
15 (GMT-10:00) Hawaii
16 (GMT-11:00) Midway Island, Samoa
17 (GMT+12:00) Auckland, Wellington
18 (GMT+10:00) Brisbane
19 (GMT+09:30) Adelaide
20 (GMT+09:00) Osaka, Sapporo, Tokyo
21 (GMT+08:00) Kuala Lumpur, Singapore
22 (GMT+07:00) Bangkok, Hanoi, Jakarta
23 (GMT+05:30) Chennai, Kolkata, Mumbai, New Delhi
24 (GMT+04:00) Abu Dhabi, Muscat
25 (GMT+03:30) Tehran
26 (GMT+03:00) Baghdad
27 (GMT+02:00) Jerusalem
28 (GMT-03:30) Newfoundland
29 (GMT-01:00) Azores
30 (GMT-02:00) Mid-Atlantic
31 (GMT) Casablanca, Monrovia, Reykjavik
32 (GMT-03:00) Buenos Aires, Georgetown
33 (GMT-04:00) Caracas, La Paz
34 (GMT-05:00) Indiana (East)
35 (GMT-05:00) Bogota, Lima, Quito, Rio Branco
36 (GMT-06:00) Saskatchewan
37 (GMT-06:00) Guadalajara, Mexico City, Monterrey
38 (GMT-07:00) Arizona
39 (GMT-12:00) International Date Line West
40 (GMT+12:00) Fiji Is., Kamchatka, Marshall Is.
41 (GMT+11:00) Magadan, Solomon Is., New Caledonia
42 (GMT+10:00) Hobart
43 (GMT+10:00) Guam, Port Moresby
44 (GMT+09:30) Darwin
45 (GMT+08:00) Beijing, Chongqing, Hong Kong S.A.R., Urumqi
46 (GMT+06:00) Almaty, Novosibirsk
47 (GMT+05:00) Islamabad, Karachi, Tashkent
48 (GMT+04:30) Kabul
49 (GMT+02:00) Cairo
50 (GMT+02:00) Harare, Pretoria
51 (GMT+03:00) Moscow, St. Petersburg, Volgograd
53 (GMT-01:00) Cape Verde Is.
54 (GMT+04:00) Baku
55 (GMT-06:00) Central America
56 (GMT+03:00) Nairobi
57 (GMT+01:00) Sarajevo, Skopje, Warsaw, Zagreb
58 (GMT+05:00) Ekaterinburg
59 (GMT+02:00) Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius
60 (GMT-03:00) Greenland
61 (GMT+06:30) Yangon (Rangoon)
62 (GMT+05:45) Kathmandu
63 (GMT+08:00) Irkutsk, Ulaan Bataar
64 (GMT+07:00) Krasnoyarsk
65 (GMT-04:00) Santiago
66 (GMT+05:30) Sri Jayawardenepura
67 (GMT+13:00) Nuku’alofa
68 (GMT+10:00) Vladivostok
69 (GMT+01:00) West Central Africa
70 (GMT+09:00) Yakutsk
71 (GMT+06:00) Astana, Dhaka
72 (GMT+09:00) Seoul
73 (GMT+08:00) Perth
74 (GMT+03:00) Kuwait, Riyadh
75 (GMT+08:00) Taipei
76 (GMT+10:00) Canberra, Melbourne, Sydney
77 (GMT-07:00) Chihuahua, La Paz, Mazatlan
78 (GMT-08:00) Tijuana, Baja California
79 (GMT+02:00) Amman
80 (GMT+02:00) Beirut
81 (GMT-04:00) Manaus
82 (GMT+03:00) Tbilisi
83 (GMT+02:00) Windhoek
84 (GMT+04:00) Yerevan

For more details regarding the TimeZone Ids, check out this MSDN link.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.