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

前端 未结 13 554
终归单人心
终归单人心 2021-02-02 06:22

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?

相关标签:
13条回答
  • 2021-02-02 06:53

    check django_timezones! this may help others too it consists of all other timezones for references

    0 讨论(0)
  • 2021-02-02 06:54

    Keep TIME_ZONE = 'Asia/Kolkata' in settings.py file and restart the service from where you are accessing the timezone (server or shell). In my case, I restarted the python shell in which I was working and it worked fine for me.

    0 讨论(0)
  • 2021-02-02 07:02

    Simple Change TIME ZONE from 'UTC' to 'Asia/Kolkata' remember K and A is Capital here.

    0 讨论(0)
  • 2021-02-02 07:05

    Django stores timestamp so if we just change the TIME_ZONE variable Django will handle rest.

    TIME_ZONE =  'Asia/Kolkata'
    
    0 讨论(0)
  • 2021-02-02 07:07

    Modify setting.py and change the time zone to TIME_ZONE = 'Asia/Kolkata'

    0 讨论(0)
  • 2021-02-02 07:08
    TIME_ZONE =  'Asia/Kolkata'
    
    USE_I18N = True
    
    USE_L10N = True
    
    USE_TZ = True
    

    The above settings should work

    0 讨论(0)
提交回复
热议问题