MongoDB TimeZone MongoDB TimeZone mongodb mongodb

MongoDB TimeZone


Daylight Saving Time

MongoDB stores dates in UTC by default.

As you are in the Middle European Timezone this means there is either a one or two hour difference depending whether the date falls in or outside the Daylight Saving Time (DST) period. In 2015 DST started on the 29th of March and ended on the 25th of October. Therefore there is a one hour offset for the 28th of December and a 2 hour offset for the 5th of April.

If you want to prevent this, you should convert your local datetime values to UTC times before saving them to MongoDB. Or, as Markus Mahlberg pointed out, convert to local time after loading the date.


You can convert it to local time.

DateTime startDate = dateFromDb.ToLocalTime();

You could also create a property like this:

DateTime _startDate = DateTime.Now;public DateTime StartTime { get => _startDate; set => _startDate = value.ToLocalTime(); }