0
I’m performing a sequel, but when I return the information that was recorded, returns with 3 hours above the postgres. json Insomnia:
Given in postgres:
I tried to change Timezone in sequelize, but this impacts again in the bank.
the correct time is postgres, soon after executing the create method and return the object should return the same value saved in postgres.
Could you help me please?
In JSON, the "Z" at the end indicates that the date is in UTC. E 20:24 in UTC is the same as 17:24 in offset -03:00 (the
-03
indicates that it is 3 hours behind UTC, so 17:24-03 is equal to 20:24Z. That is, the date/time (the instant, the point on the timeline) is exactly the same. What changes was only the representation of the same (both...– hkotsubo
Now I get it! Thank you very much!! Could you tell me some way to return the same date and time in the json if possible?
– Lucas Souza
It depends on where/how you query the date and show it (will it be in Javascript? Or in another language? etc). Please click [Edit] and add these details. Remembering that if it is "just" a matter of converting and/or formatting the date, there are already several questions on the site about it, so be sure to do a good search before, to make sure that your problem has not been solved before :-)
– hkotsubo
Yes javascript, I am using the sequelize model with the timestamp functions, I would just like to be able to convert the return of json to the correct time zone, because if I need to print this date it comes according to which was saved in the database.
– Lucas Souza
But then, in the bank was saved "some date", not necessarily the date you see. The postgres is showing it in Brazilian time zone, but nothing guarantees that what is recorded there is in this time zone. Even, if I’m not mistaken, you can change the bank’s spindle configs and it shows the date in that other zone. What is written is some value that is equivalent to 20:24Z and also 17:24-03. Both are the same instant. Either way, conversion between spindles with the
Date
do JS is quite limited, search on libs like Moment.js and date-fns– hkotsubo