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:Jump to 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
10 Replies
Project ID:
N/A
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
ID: eight-shade
project ids are uuidv4's
id: a43880ef-416c-4ed6-9d95-76d997c5f93d
a43880ef-416c-4ed6-9d95-76d997c5f93d
^
is there an explanation why changing TIME_ZONE setting affect RAilway, but not Heroku?
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
Ok thanks
SOLVED
awsome!