Storing date/time values in databases
You should only store UTC date/time values in your databases.
In Sitecore version 8.0 and later, only UTC date/time values should be saved to the database. There can be legacy date/time values in existing Sitecore databases and you need to be able to distinguish UTC date/time values and legacy date/time values. So, for string representations of date/time values, ‘Z’ is added to the existing format to indicate UTC (for example, ‘20131031T083552Z’). The methods of the Sitecore.DateUtil
class responsible for parsing and converting date/time values to strings have been updated and can handle the ‘Z’ notation correctly.
Sitecore databases store date/time values not only as string values. There are tables that contain datetime
columns, but they might not store information about time zone. Therefore, all dates in the databases should be treated as UTC and date/time kind should be explicitly set to UTC when reading date/time values from the database.
The following is an example of reading a date/time value from the database:
DateTime startDate = reader.InnerReader.GetDateTime(13).SpecifyKind(DateTimeKind.Utc);