postgresql database date error

Good afternoon, my name is Diego, I am a Brazilian from the city of Ribeirão Preto and I am working on a project that uses an instance of Postgresql from Railway, the problem is that when I insert a date data in a certain column of a table, either manually how much for a software, the value that is saved is from the previous day always, how can i fix this? The project id is 67285da8-bb3c-4d6a-9149-8d8d78dfc364 (It is from a alternative railway account).
Solution:
the date is saved in UTC time, this is completely normal. you will want to convert the dates from the database to your local timezone only when needed, and keep the database dates in UTC...
Jump to solution
6 Replies
Percy
Percy2y ago
Project ID: 67285da8-bb3c-4d6a-9149-8d8d78dfc364
Solution
Brody
Brody2y ago
the date is saved in UTC time, this is completely normal. you will want to convert the dates from the database to your local timezone only when needed, and keep the database dates in UTC
Diego Dreossi
Diego Dreossi2y ago
The project that requires the postgresql db is a django site, in the project settings the variables are these: TIME_ZONE = 'America/Sao_Paulo', USE_I18N = True, USE_TZ = True, and when i was using the sqlite as db to test it was workink just fine when i was running the server. Do you know how I can save dates in my time zone without causing more problems?
Brody
Brody2y ago
it's recommended to keep database times in UTC and convert out to your desired timezone when needed
Diego Dreossi
Diego Dreossi2y ago
I am developing a website to a podcast, i have a couple of features that use date to execute your command, and these date need to be in my timezone. So i need convert convert the timezone, how to do it?
Brody
Brody2y ago
I'm sure there's are plenty of tutorials out there on how to convert from UTC
Want results from more Discord servers?
Add your server