# A strange problem in django.utils.timezone

**URL:** <https://forum.djangoproject.com/t/a-strange-problem-in-django-utils-timezone/13837>\
**Category:** Forms & APIs\
**Created:** [May 21, 2022, 2:22pm UTC](https://forum.djangoproject.com/t/a-strange-problem-in-django-utils-timezone/13837 "2022-05-21T14:22:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![V70024](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/v70024/32/8592_2.png) [@V70024](https://forum.djangoproject.com/u/V70024)\
**Post date:** [May 21, 2022, 2:22pm UTC](https://forum.djangoproject.com/t/a-strange-problem-in-django-utils-timezone/13837/1 "2022-05-21T14:22:36Z")

</div>

**I found a strange problem in Django**  
code:

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

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

```

output:

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

```

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [May 21, 2022, 4:04pm UTC](https://forum.djangoproject.com/t/a-strange-problem-in-django-utils-timezone/13837/2 "2022-05-21T16:04:31Z")

</div>

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](https://docs.djangoproject.com/en/4.0/topics/i18n/timezones/)

> 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.

---

<div class="post-metadata">

**Author:** ![V70024](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/v70024/32/8592_2.png) [@V70024](https://forum.djangoproject.com/u/V70024)\
**Post date:** [May 21, 2022, 5:21pm UTC](https://forum.djangoproject.com/t/a-strange-problem-in-django-utils-timezone/13837/3 "2022-05-21T17:21:29Z")

</div>

Thanks for your help  
I used this method

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

```
