Storing date/time values in databases

Current version: 9.0

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:

RequestResponse
DateTime startDate = reader.InnerReader.GetDateTime(13).SpecifyKind(DateTimeKind.Utc);

Do you have some feedback for us?

If you have suggestions for improving this article,