Django 时间戳不一致
我正在开发一个工作安排网络应用程序,但遇到了一个非常奇怪的问题。该应用程序使用 Django 和 FullCalendar。在应用程序中,用户可以在 FullCalendar 中创建事件,并将开始和结束时间存储为 PostgreSQL 数据库中的日期时间字段。当事件返回到日历时,我使用 Django DateTag 将时间转换为 UnixTimestamp。除了所有事件的时间戳都会提前一小时随机返回之外,一切都运行良好。大约每隔几次我访问该页面,时间戳就会偏离一小时。
有其他人遇到过类似的问题并能够找到解决方法吗?
I'm working on a scheduling web application for work and am having a very weird problem. The application uses Django and FullCalendar. In the application users can create an event in FullCalendar and the start and end time get stored as a DateTime field in a PostgreSQL database. When the events are returned to the calendar I use a Django DateTag to convert the times to a UnixTimestamp. Everything works perfectly except that the timestamp will randomly be returned one hour early for all events. About every few times I access the page the timestamp will be off by one hour.
Has anyone else experienced a similar problem and been able to find a fix?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来很可疑,像是时区问题,可能涉及夏令时。
您知道 PostgreSQL 中这些 类型 的差异吗?
请注意差异:
您可能会在章节中找到线索时区。
转换时间戳列很简单。只截掉时区部分:
将所有时间转换为特定时区,例如“UTC”:
Suspiciously sounds like a timezone problem, possibly involving daylight saving time.
You are aware of the differences with these types in PostgreSQL?
Note the difference:
You may find a clue in the chapter on time zones.
Converting timestamp columns is simple. To just cut off the timezone part:
To convert all times to a specific timezone, for instance 'UTC':
如果这是实时服务器,您可能需要检查 .conf 文件中的时间戳设置?
例如,您可能会发现在
/etc/httpd/conf/httpd.conf
并添加以下行
setenv TZ America/
If this is a live server perhaps you need to check the .conf files for timestamp settings?
For example you may find that at
/etc/httpd/conf/httpd.conf
And add the following line
setenv TZ America/<Timezone>