'MongoDB insert is altering date from object to input?
I have a small problem where an object that I insert into a mongoDB collection has a different DateTime value as soon as it is inserted.
It actually changes exactly -13 hours.
The date from the object to insert is: {2/16/2022 12:00:00 AM}
The date from the object in the DB after adding it is: 2022-02-15 23:00:00.000Z
Am I missing some kind of cast or anything?
This is the insert function:
public void Add(string sCollectionName, T tObjectToInsert)
{
try
{
IMongoCollection<T> mcMongoDBCollection = m_dbDatabase.GetCollection<T>(sCollectionName);
mcMongoDBCollection.InsertOne(tObjectToInsert);
}
catch (Exception e)
{
throw (new System.Exception("Error during insert in MongoDB. Code: " + e.Message));
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
