首页 > 解决方案 > 根据我的时区,我没有时间

问题描述

我住在印度,现在时间是 2020 年 8 月 10 日上午 5:14,但在我的项目中使用这个时间我得到了不同的时间 2020 年 10 月 7 日晚上 11:41

from django.utils.timezone import now  
timeStamp=models.DateTimeField(default=now)

标签: pythondjangodjango-modelsdjango-viewsdjango-templates

解决方案


在 settings.py

# Internationalization
# https://docs.djangoproject.com/en/3.1/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'Asia/Manila' #change this according to your timezone

USE_I18N = True

USE_L10N = True

USE_TZ = True

推荐阅读