The time zones in Moment come from the IANA Time Zone Database. It is different with the time zones available in SharePoint. If you are planning on using moment.js to do time conversions between time zones, then you will need the mapping between IANA Time Zones and SharePoint time zones. The SharePoint time zones are based on UTC offsets. It has a unique ID for each time zone. The following is the mapping between the SharePoint Time Zone ID, SharePoint Time Zone name and IANA time zone.
|ID||SharePoint Time Zone||IANA Time Zone|
|2||(GMT) Greenwich Mean Time : Dublin, Edinburgh, Lisbon, London||Europe/London|
|3||(GMT+01:00) Brussels, Copenhagen, Madrid, Paris||Europe/Paris|
|4||(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna||Europe/Berlin|
The full mapping in an Excel sheet is available here:
SharePoint Time Zone to SharePoint Time Zone ID
SharePoint Time Zone ID to IANA Time Zone
Choosing a Global Software Development Partner to Accelerate Your Digital Strategy
To be successful and outpace the competition, you need a software development partner that excels in exactly the type of digital projects you are now faced with accelerating, and in the most cost effective and optimized way possible.
SharePoint Time Zone ID to SharePoint Time Zone
Here are the examples for how to use it:
// Convert SharePoint Time Zone “(UTC-08:00) Pacific Time (US and Canada)” to its Time Zone ID
var id = SPTimeZoneNameToSPTimeZoneId[“(UTC-08:00) Pacific Time (US and Canada)”];
// Output: id is 13
// Get time zone ID (13) to its IANA Time zone name
var IANATimeZoneName = SPTimeZoneIdToIANATimeZoneName[“13“];
// Output: IANATimeZoneName is America/Los_Angeles
The complete mapping file is available here.
With the help of these mapping JSON objects, you are now able to use my favorite moment.js library to do the time zone conversions in SharePoint.
Please leave a comment if you find any invalid mapping.