Home » Django & REST Api » How to set / change the timezone in Django ?

How to set / change the timezone in Django ?

If you have followed to create your first django project “Starting webserver using your first simple Django project” , the default timezone “TIME_ZONE” argument is set to “UTC” as we can see in “my_django_project/settings.py”

# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/



USE_I18N = True

USE_L10N = True

USE_TZ = True

Now, if you want to change the Time zone check the corresponding “TZ Database name” string from https://en.wikipedia.org/wiki/List_of_tz_database_time_zones and modify “TIME_ZONE”,

so for example, if we want to change timezone to India then change TIME_ZONE to “Asia/Kolkata” as seen from wikipedia link.

For other variables,

USE_I18N refer to https://docs.djangoproject.com/en/3.0/ref/settings/#use-i18n

USE_L10N refer to https://docs.djangoproject.com/en/3.0/ref/settings/#use-l10n

When USE_TZ is False, time zone set from 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.

Subscribe our Rurban Life YouTube Channel.. "Rural Life, Urban LifeStyle"

Leave a Comment