RavenDB version 2.0. Other versions:

Storing dates in RavenDB

How should I store dates in RavenDB? Using UTC? Using Local Time?

When you store a date to RavenDB, it will save whether it's UTC or not. When it's not UTC, a local date is treated as "Unspecified".

However if you have people from around the world using the same database, and you use unspecified local times, the offset is not stored. If you want to deal with this scenario you need to store the date using a DateTimeOffset that will store the date and time, and its time zone offset.

The decision of whether to use UTC, or Local Time, or DateTimeOffset is an application decision, not an infrastructure decision. There are valid reasons for using any one of these.

More Information

For detailed information about this topic, please refer to the Working with Date and Time in RavenDB knowledge base article.

Comments add new comment

The comments section is for user feedback or community content. If you seek assistance or have any questions, please post them at our support forums.

Matt Johnson
REPLY Posted by Matt Johnson on

Isn't this example outdated since datetimes are now serialized in ISO8601 format?

Ayende Rahien
REPLY Posted by Ayende Rahien on

Yes, it is out of date, we will update this tomorrow