[Django]-Django: "auto_now_add=True" giving incorrect time

8👍

From my understanding this automatically stamps the time considering the correct time zone.

That’s a misunderstanding. See the first sentence of the timezone documentation:

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.

As you’ve seen, that UTC datetime can then be converted to whatever you want for display, etc.

1👍

**in the models import datetime

in settings.py change the USE_TZ to False**

LANGUAGE_CODE = ‘en-us’

TIME_ZONE = ‘UTC’

USE_I18N = True

USE_L10N = True

USE_TZ = False

-1👍

In settings.py file

Keep USE_TZ value to False

USE_TZ = False

This worked for me.

Leave a comment