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/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

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,


Subscribe with Valid Email Id to receive updates in Inbox. ( Secured by Google FeedBurner )

   


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.

lynxbee_ezoic

Leave a Comment

Android Android Build system Android Commands Android Java Applications Application Libraries Application Stack / User Interface Bash / Shell Scripts Bluetooth driver Cloud Technologies Commands and Packages Compilation Content Management System Core Kernel C Programs Development & Build Development, Debugging and Performance Tools Development Environment Setup Django & REST Api Errors & Failures Git Hardware Platforms HTML JAVA Programs Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Multimedia Audio, Video, Images NDK / Middleware / HAL OS Concepts PHP Programming Languages Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Source Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Web design and development Website Hosting Wordpress Yocto / Bitbake / Openembedded