3👍
✅
from django.utils import timezone
now = timezone.now()
Also make sure that USE_TZ=True. This is automatically set to False. If this isn’t set to True then timezone.now() will not be set to your timezone.
3👍
Django uses its module django.utils.timezone
to work with dates, times and perform convertions from/to locale or UTC datetimes. You can use functions from this module to do what you want.
In addition, you should read the doc to understand how Django handle localized datetime.
Source:stackexchange.com