python - 根据我的时区,我没有时间
问题描述
我住在印度,现在时间是 2020 年 8 月 10 日上午 5:14,但在我的项目中使用这个时间我得到了不同的时间 2020 年 10 月 7 日晚上 11:41
from django.utils.timezone import now
timeStamp=models.DateTimeField(default=now)
解决方案
在 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
推荐阅读
- python - 使用 Holoviews 的 TreeMaps
- ios - 如何在不点击横幅或显示通知之前访问推送通知响应?
- powershell - 我有 2 个关于 powershell 和 IIS 的问题
- dynamics-crm - 如何在 Dynamic CRM365 视图中访问我的网格
- javascript - ScrollView 中的自动滚动 react-native
- graph - 图论(图可以划分为两棵树时的顶点度)
- c# - 将 ASC 文件读取与视频帧同步,没有任何共同值
- xml - Groovy XmlSlurper 将 " 添加到所有值
- java - ArangoDB、Java、Velocypack 错误尝试反序列化 DBEntity
- security - 是否可以通过强制从正在运行的进程中提取转储文件并对其进行分析来窃取应用程序中的任何数据?