Answer the question
In order to leave comments, you need to log in
How to filter data for a month based on user time zones?
I'm using a MongoDB database
Let's say an entry is made with a date and time in UTC at night. In UTC, the entry may go to another day.
I need to further filter for example entries by month. There is a risk that some data will be lost due to the fact that different time zones are specified. How to proceed in such cases? How do we let the user filter records in his timezone?
Answer the question
In order to leave comments, you need to log in
You write the time zone as +03 or -07, and when filtering, you add or subtract the time zone value to the utc value.
those. in the database the value is 14:00, when filtering all records older than or equal to 14:00 user time
for utc time >= 14:00
for +03 time >= 17:00
for -07 time >= 07:00
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question