Django app save DateTimeField in different timezone

This is the settings.py for time zone: TIME_ZONE = "America/Toronto" USE_TZ = False Saving a field to Postgresql database doesn't save in UTC timezone, but 4 hours ahead. For example now it's 17:28 in Toronto. Saving to database saves this time: 2023-10-08 21:28:57.613 -0400 which means that's 2023-10-09 01:28:57:57.613 in UTC time. Also, datetime saved to database is affected with TIME_ZONE settings. While on Heroku it doesn't change anything. Heroku still save correct time. Why is that? How to fix it?
Solution:
railways servers are in utc, make sure everything you do is in utc until you need to convert to your local timezone for display purposes
Jump to solution
10 Replies
Percy
Percy10mo ago
Project ID: N/A
Solution
Brody
Brody10mo ago
railways servers are in utc, make sure everything you do is in utc until you need to convert to your local timezone for display purposes
webomania
webomania10mo ago
ID: eight-shade
Brody
Brody10mo ago
project ids are uuidv4's
webomania
webomania10mo ago
id: a43880ef-416c-4ed6-9d95-76d997c5f93d a43880ef-416c-4ed6-9d95-76d997c5f93d
Brody
Brody10mo ago
^
webomania
webomania10mo ago
is there an explanation why changing TIME_ZONE setting affect RAilway, but not Heroku?
Brody
Brody10mo ago
heroku does a whole lot of handholding, they are likely patching your code in some way or another, railway will only run your code as-is
webomania
webomania10mo ago
Ok thanks SOLVED
Brody
Brody10mo ago
awsome!