You are currently browsing legacy 4.0 version of documentation. Click here to switch to the newest 5.1 version.
Client API: How to Store Dates in RavenDB Using UTC and 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, Local Time, or
DateTimeOffset is an application decision, not an infrastructure decision. There are valid reasons for using any one of these.
ISO 8601 Compliance and Default Storing Formats
RavenDB is ISO 8601 compliant.
The default storing format for
DateTime is : "yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffff"
DateTimeOffset, RavenDB uses the Round-trip ("o") format
For detailed information about this topic, please refer to the Working with Date and Time in RavenDB article written by Matt Johnson.