Hello, I’m trying to query a Date record (called ‘my_timing’) in my collection based on my current date, but new Date() in mongosh only returns UTC.
I’m running this query in the filter window inside Mongo Compass.
Is there a way to change the timezone used in my query to run against my ow timezone (UTC+4) ? I want my current time to be UTC + 4 and then get all the records that are less than my current time by a maximum delta time difference of 1 hour.
This is an example of what I’m trying to achieve:
{
my_timing: {
$gte: {
$dateAdd: {
"startDate": new Date().setUTCHours(new Date().getUTCHours() + 4),
"unit": "hour",
"amount": -1
}
},
$lte: {
$dateAdd: {
"startDate": new Date().setUTCHours(new Date().getUTCHours() + 4),
}
}
}
}
When I try to run this query, no error arises but no documents are returned despite the fact that there are valid documents for this query.
Thank you for the help.