Home > Net >  How to convert time to different timezone in django python
How to convert time to different timezone in django python

Time:09-10

I am trying to convert time from America/New_York to other(any) timezone using

from django.utils import timezone

I tried finding references on web but couldn't find it

CodePudding user response:

If you'd like to import from dateutil.tz, this could probably help!

from dateutil.tz import *
from django.http import HttpResponse
from django.utils import timezone
def date(request):
    return HttpResponse(f"Time: {timezone.datetime.now().replace(tzinfo=tzutc())}")

CodePudding user response:

Tested it's working modify into settings.py file

TIME_ZONE = 'Asia/Kolkata'

CodePudding user response:

Change TIME_ZONE variable in settings.py from utc to ...

  • Related