My api generates dates and saves them to a database which then will be read by the client.
Right now when I generate a date object (doing new Date()
) in node I get this:
2022-10-27T19:30:00.400Z
This is, as I understand, UTC+00, because when I insert that date in my postgres database (which have UTC set as its timezone) I get this (column type is timestampz):
2022-10-27 19:30:00.400+00
Now because the date object is being generated on the server side (which doesn't have the same timezone as the client), the client also sends its timezone offset in the get request.
My question is how can I modify the timezone of a date object? so instead of the last date I can obtain something like this:
2022-10-27 19:30:00.400-05
when inserting it to the database.