Storing date/time values in databases

Abstract

You should only store UTC date/time values in your databases.

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);