Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add Indian Standard Time (IST) in Django?

Tags:

python

django

We want to get the current time in India in our Django project. In settings.py, UTC is there by default. How do we change it to IST?

like image 789
Alok Avatar asked Feb 18 '14 13:02

Alok


People also ask

How do I get local timezone in Python?

You can get the current time in a particular timezone by using the datetime module with another module called pytz . You can then check for all available timezones with the snippet below: from datetime import datetime import pytz zones = pytz. all_timezones print(zones) # Output: all timezones of the world.

What is Use_tz in Django?

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.


1 Answers

Change the field TIME_ZONE in the settings.py. For the Indian standard time you will need:

TIME_ZONE =  'Asia/Kolkata' 

For more information about the TIME_ZONE in Django you can see: https://docs.djangoproject.com/en/dev/ref/settings/#time-zone

like image 70
Jon Avatar answered Oct 08 '22 09:10

Jon