Mongodb stores date object in UTC. I need to query client entered tasks based on "today". Today varies from the user's perspective, who can be in Eastern time zone or Pacific. Here's the issue I ran into:
Record is entered as "2017-05-10 15:15:11.283Z". When I query the server later at night, the server date will be already 2017-05-11, however from the client's perspective it is still 2015-05-10.
I need to find all the tasks client entered "today".
I tried this:
let start = new Date();
start.setHours(0,0,0,0);
let end = new Date();
end.setHours(23,59,59,999);
But while that works during the day (same day), it does not show the records when the client queries at night, but before midnight.
via Florida Gard
No comments:
Post a Comment