Correct insert DateTime from c# to mongodb

后端 未结 4 832
情歌与酒
情歌与酒 2020-12-29 13:52

I try to insert local time in MongoDB

var time = DateTime.Now; // 03.05.2014 18:30:30

var query = new QueryDocument
{
   { \"time\", nowTime}
};

collection         


        
4条回答
  •  我在风中等你
    2020-12-29 14:34

    It could work with:

        DateTime t = DateTime.Now;
    
        var update = Builders.Update
        .Set("key1", t.ToUniversalTime())
        .CurrentDate("key_updatetime");
    

提交回复
热议问题