A strange problem in django.utils.timezone

I found a strange problem in Django

from django.utils import timezone
from Blog.settings import TIME_ZONE

print(" django.utils.timezone.now: {0}  |  settings.TIME_ZONE: {1}  ".format(


django.utils.timezone.now: UTC  |  settings.TIME_ZONE: Asia/Tehran  

Why do you think that’s either “strange” or a “problem”? This looks like perfectly reasonable behavior to me.

From the docs at: Time zones | Django documentation | Django

When support for time zones is enabled, Django stores datetime information in UTC in the database, uses time-zone-aware datetime objects internally, and translates them to the end user’s time zone in templates and forms.

Since you’re not using that value in a template or a form, I see no reason why it shouldn’t be stored internally as UTC.

1 Like

Thanks for your help
I used this method

from django.utils import timezone
time = timezone.localtime(time)