I'm developing a client and server application and I'm using luxon and postgres.
Considering the current time i'm writing this post (2022-11-15T22:55:27.374-03):
- On local server/db, the dates are saved on UTC-3, like the above (2022-11-15T22:55:27.374-03);
- On hosted server/db, the dates are saved on UTC-0 (2022-11-16T01:55:27 00);
My problem is that i need to query data in between begin and end of day, and while on local it works, on server it doesn't because day starts at 03:00 and finishes on next day 02:59.
I tried hardcoding conditional offset based on env but i dont believe that this should be the best solution...
Is there a proper way to handle this timezone difference?
CodePudding user response:
You need to define what beginning and end of day mean. There are a total of 48 hours in which any timezone can be in a particular date. You'll have to decide if your queries will be "today" in the server's timezone or in the local client's timezone. If your queries are the server's "today". You can parse any request as plain timestamps and let the receiver decide what bounds to use. The flip side is to request the actual date string you want e.g. 2020-01-01
and let the server calculate the bounds in its timezone.