I have an issue with Nestjs Mongoose about Date query I used Mongoose for my project. I want to query some documents based on Date field
My query looks like: this.model.find(startDate: {$gte: new Date().toUTCString()})
So it will convert to: 2023-05-17T09:37:23.592Z
like this
And in my db. I have a record that has startEnd: 2023-05-17T12:30:23.306+00:00
I expected to get the doc but it didn't
But if I pasted above query to MongoDB Compass. It worked
When I console.log in pre hook find
. It logged 2023-05-17T09:37:23.592Z
But when I open Mongo debug mode.
It shows: collection.find({ startDate: { '$lte': new Date("Wed, 17 May 2023 09:51:24 GMT") } }, { projection: null })
I don't know why it printed GMT here?
I use Window, Mongodb Docker with version 6.x
Please help me. Thanks in adavance