A
A
andreyAmaterasu2020-07-11 16:27:34
Django
andreyAmaterasu, 2020-07-11 16:27:34

How to set timezone in Django?

The essence of the problem is that the time on the Django server is 5 hours behind the current one. That is, as you can see on the screenshot, the time on the server is 13:09, datetome.now() also returns 13:09, although the current time is 18:09. 5f09be75900f5003255461.png
The settings.py file originally had the following settings: TIME_ZONE = 'UTC' and USE_TZ = True. I was able to get the current time by manually setting the time zone, but I think that this is not the best approach, and it would be better if the time zone was determined automatically. Does anyone know how this can be implemented?5f09be3327725305840244.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2020-07-11
@andreyAmaterasu

what is the current time?
- there is a time zone that is set on the server
- there is a time zone that is set on django, TIME_ZONE
- there is a time zone that each client has its own
- there is a django setting, whether or not to use TIME_ZONE
- there are two types of date, "Naive and aware datetime "
Deal with all this, then maybe you will understand what exactly you need. Read the docs in detail https://docs.djangoproject.com/en/3.0/topics/i18n/... especially the FAQ at the end

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question