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开发者_JS百科 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
"In Sitecore version 8.0 and later, only UTC date/time values should be saved to the database." https://doc.sitecore.com/en/developers/102/sitecore-experience-manager/storing-date-time-values-in-databases.html
More on the matter: https://doc.sitecore.com/en/developers/102/sitecore-experience-manager/utc.html
Try keeping all date/times in UTC and convert them to EST, PTS etc on render time. By using .Net TimeZoneInfo class you can simply convert the stored UTC value to a suitable time zone at render time. This will solve day light saving issues as well.
Sitecore doesn't have much support for this, but to make things easier for content authors, you can extend the Sitecore DateTime field to include time zone drop down as it is entered into the CMS. The extended field type should handle conversion between UTC and content authors preferred time zone.
You can also extend the user profile so that content authors can store their preferred time zone. You should also run your servers on UTC time, but since you're already live with EST it might not be a very good idea to change it.
Also worth of mentioning that in case you have few geographically distributed servers, you should have them not just in UTC, but synchronised. This applies to everything including DMS and xDB instances as well.
If not, it will break Event Queue and remote events (like publishing) as that all works through core database and (by default) is checked for new events (which in fact are records in database with appropriate timestamp).
精彩评论