I am comparing person date of birth which is stored as UTC format by client side with current date at 00:00 on time zone asia/kolkata, but it gives me the previous previous date data. I mean at 00:00:00 at 17-mar-2021 i fired the query, It should check that is there any entries whose date and month in date of birth matches to 17 of March? But it compares with 16 of march, I don’t figure out why this is happening.
Query
const userFound = await Contact.find({
$expr: {
$and: [
{ $eq: [{ $dayOfMonth: '$dob' }, { $dayOfMonth: new Date() }] },
{ $eq: [{ $month: '$dob' }, { $month: new Date() }] },
],
},
});
Here, dob stores the data of birth of person in UTC format (e.g. ‘2021-03-17T00:00:00.000+00:00’) .
Also I have tried it in morning its work fine, But at 00:00:00 it won’t. Why it is happening and what its solution?