PHP strtotime 返回 Mysql UNIX_TIMESTAMP 的不同值

标签 php mysql datetime

我在 stackoverflow 上搜索过帖子,找到了一些类似的帖子。但我认为这是不同的帖子。

我的 PHP 和 Mysql 服务器的时区都设置​​为“UTC”。

在我使用时间戳字段的表中,值为“2010-11-08 02:54:15”,我这样使用 sql:

SELECT id, 
       updated, 
       second( updated ) , 
       unix_timestamp( updated ) 
  FROM `transaction` 
 where id = 56

明白了:

id  updated              second  unix
--------------------------------------------
56  2010-11-08 02:54:15  15      1289184879 

然后我在 php 中使用它:

echo strtotime("2010-11-08 02:54:15");

明白了:

1289184855

不同的是24秒。

我在 http://www.unixtimestamp.com/index.php 上检查了这些时间戳 php 结果是正确的。那么mysql的unix_timestamp函数有bug吗? Mysql版本为:5.1.41

最佳答案

确认为bug,5.1.44修复

参见 http://bugs.mysql.com/bug.php?id=51918有关详细信息,错误发布者已准确找到此问题。

你别无选择,只能通过升级来避免这种情况。

关于PHP strtotime 返回 Mysql UNIX_TIMESTAMP 的不同值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4121039/

相关文章:

mysql - REPLACE INTO SQL 语法错误

python - 如何在数据框中正确设置 Pandas 日期时间对象的 Datetimeindex?

c# - DateTime.Compare 如何检查日期是否小于 30 天?

android - 数据范围过滤器在 Android 中使用的 SQLite 中不起作用

php - 如何将两个 foreach 循环合并为一个

java - WSDL 中没有指定操作

javascript - 突出显示表格

mysql - "Foreign key constraint is incorrectly formed"

php - PHP 7 中属性的类型提示?

php - 无法使密码加密工作 PHP