Having trouble comparing dates to check if new day has started

Hi all,

I am new to MongoDB/programming and am building a habit tracking app that needs to reset the user’s habits to be clicked: false when a new day has started. I am having trouble figuring out how to do this.

I am currently sending the users timezone as a string when a new habit is created and sending the date when a habit was last clicked. I have used moment.js to have this date be at the start of the day, as I don’t need to account for hours/mins/seconds. It appears in the db like so:

lastCompleted : 2023-02-10T00:00:00.000+00:00

I am wondering how I can convert this date to the users local time on the server and check if it has rolled over into a new day. I have been stuck on this for a while now.

Any help is much appreciated.