database - 为什么 Wordpress 使用两列来存储发布日期

标签 database wordpress datetime

我在 wp_posts 表上看到 wordpress 数据库,有 2 列存储发布日期,post_datepost_date_gmt

post_date_gmt 以 GMT 时间存储发布日期。 post_date 将发布日期存储在创建帖子的用户时间中。我说得对吗?

将两个版本的发布日期都存储在数据库中有什么好处吗?

当用户想要根据他/她的时区查看发布日期时,存储两个版本的发布日期而不是使用用户时区计算 post_date_gmt 是否更快

更新: 我也在现场询问并得到这个答案

The one benefit it would provide is that if the person moves to a different timezone then their earlier posts still record what time it was where they were when they posted them and not what time it was where they are now (as would be all you could calculate using the GMT time and their current timezone).

http://www.sitepoint.com/forums/showthread.php?p=4671837

最佳答案

不确定口译员的速度。他们使用 GMT 的一个重要原因实际上是它使日期时间更便携并且不受特定时区的约束,并允许您编写更通用和国际化的代码。为什么他们保存两者很好奇,但 GMT 格式绝对是数据库存储的首选。

关于database - 为什么 Wordpress 使用两列来存储发布日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3474632/

相关文章:

database - 类型 'DocumentSnapshot' 不是类型 'Map<String, dynamic>' 的子类型

java - 如何检查连接池是否被使用

html - 如何为 IMG 标签内的图像添加悬停边框?

MySQL 查询返回所有产品和不带缩略图的 SKU

MySQL - SEC_TO_TIME 给出相同的结果,无论组如何

php - 在数据库中使用 ID

database - 防止数据库设计中的循环引用

php - 如何使用复选框来检索数据库中的特定数据

datetime - 如何处理新时区?

python - 在 groupby 数据框中查找给定日期的最接近日期(Python)