The current Date/Time picker in Sitecore assumes the local system time of the CM server (Eastern Standard/Daylight Time, in our case) when we choose dates and times for our Events.
It quickly became apparent that we needed a way for content authors to choose timezones for events. Initially, we decided to provide a Droplist of predefined timezone abbreviations such as ''PST', 'EST', 'EDT', etc. While this solution worked OK for display purposes, we immediately ran into problems when trying to dynamically generate .ICS calendar appointments for the events.
In order to generate .ICS files, we need a way to combine the Event's start and end date (which again is in EST or EDT) and the timezone abbreviation (EST, PST, etc.) into a UTC DateTime object.
It is my understanding that ASP.NET does not support timezone abbreviations, so I believe we are stuck maintaining a list of abbreviations along with their UTC offset values. It is not enough to give our content authors a list of timezones such as GMT -08:00, GMT -07:00, etc., we need to include some sort of abbreviation or name to help them make the selection.
Does Sitecore have any built-in fields or utilities for selecting Timezones?
Sitecore does not have a built-in template to store timezone but you can easily create your own template to do so. I recommend you change your Droplist
to a Droplink
(a droplist references the referenced item by name, a droplink references the referenced item by GUID) then create a new template for the source. Your new template can be something called Timezone. The name of each item can be the friendly name (e.g. EDT, PDT, etc) and there can be one field on the item, an Offset. In your code, when you determine what item is picked from the now Droplink, you can access the Offset field on it to determine the actual offset. Something like this:
ReferenceField timezoneSelected = item.Fields["Timezone"];
string offsetVal = timezoneSelected.TargetItem.Fields["Offset"].Value;
// parse out the true value from offsetVal
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With