Reputation: 2813
I have an application which is using 'Asia/Taipei' as its timezone in settings.py and using the auto_now=true on one of the datetimefield on models.py:
--- settings.py ---
TIME_ZONE = 'Asia/Taipei'
--- models.py ---
models.DateTimeField(auto_now=True)
On my system, Taipei is also used as my timezone:
On the MySQL Workbench, I already queried for both global and session tz and their returns are "SYSTEM":
My question is when an entry is added to DB, the timezone specified on the system and on settings.py was not used. See sample snapshot:
What am I lacking? Doing wrong? Thanks in advance!
Upvotes: 3
Views: 4661
Reputation: 7760
Typically, database will store the UTC time by default and the corresponding application will do the conversion based on the settings/configurations.
In your case, it depends on your USE_TZ
setting.
When USE_TZ is False, this is the time zone in which Django will store all datetimes. When USE_TZ is True, this is the default time zone that Django will use to display datetimes in templates and to interpret datetimes entered in forms.
For more details, you can refer
Upvotes: 6