0

I've enabled USE_TZ as True and added TIME_ZONE as Asia/Calcutta in settings.py

So when I am inputting a date like datetime(2021, 11, 24) it is stored in db as 2021-11-23T18:30:00+00:00 which is fine.

But when I am getting the date in shell, it is not converting back in IST and just giving me datetime.datetime(2021, 11, 23, 18, 30, tzinfo=<UTC>) and whenever I have to display the date, it is showing 23 instead of 24 and I have to convert it manually everywhere like that:

from django.utils import timezone

if timezone.is_aware(status_time):
        status_time = timezone.localtime(status_time)

But strangely in django admin it is showing me IST dates but not in django shell or anywhere else.

Is this the only way or I can have auto IST converted dates somehow?

brainLoop
  • 3,190
  • 2
  • 9
  • 12
Siraj Alam
  • 7,620
  • 6
  • 46
  • 63
  • You need to set `USE_TZ` as `False`. Check [this answer](https://stackoverflow.com/a/14714819/10819573), [this answer](https://stackoverflow.com/a/46886463/10819573), and [this documentation](https://docs.djangoproject.com/en/3.2/topics/i18n/timezones/) to learn more about it. – Arvind Kumar Avinash Oct 28 '21 at 18:28

0 Answers0