3

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: enter image description here

On the MySQL Workbench, I already queried for both global and session tz and their returns are "SYSTEM": enter image description here

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: enter image description here

What am I lacking? Doing wrong? Thanks in advance!

0

2 Answers 2

6

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

Sign up to request clarification or add additional context in comments.

Comments

4

it's working now. I just set USE_TZ = False

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.