简体   繁体   English

使用phpMyAdmin导出会更改时间戳

[英]Exporting with phpMyAdmin changes timestamps

When exporting a file through phpMyAdmin some timestamps are put back an hour. 通过phpMyAdmin导出文件时,一些时间戳记会推迟一个小时。 How may I prevent this? 我该如何预防? I do not want timestamps tampered with. 我不想篡改时间戳。 Here's a screenshot for the curious (see the dates.) 这是好奇的屏幕截图 (请参阅日期。)

I believe the cause may be the SET time_zone = "+00:00"; 我相信原因可能是SET time_zone = "+00:00"; that is added to every export file. 会添加到每个导出文件中。

Is this suppose to happen? 这应该发生吗? Is it a known bug? 这是一个已知的错误吗?

I'm running: 我在跑:

-- Server version: 5.5.37-0ubuntu0.14.04.1
-- PHP Version: 5.5.9-1ubuntu4

The times are not actually being 'tampered with'. 时代实际上并没有被“篡改”。

MySQL interally stores TIMESTAMP columns converted to UTC time , then uses a mixture of system and session (client session) values to determine what to display to the user. MySQL在内部存储转换为UTC时间的 TIMESTAMP列,然后使用系统和会话(客户端会话)值的混合来确定向用户显示什么。

You can check both of these values running the following query yourself. 您可以自己运行以下查询来检查这两个值。

SELECT @@global.time_zone, @@session.time_zone;

So when your PHPMA script generates its dump, its specifying a session time_zone variable so when you run it MySQL will convert them all from that timezone back to UTC. 因此,当您的PHPMA脚本生成其转储时,它会指定一个会话time_zone变量,因此当您运行它时,MySQL会将它们全部从该时区转换回UTC。 When you then go to import that to another database, it will still convert them back to the UTC values you're expecting. 然后,当您将其导入到另一个数据库时,它将仍然将它们转换回您期望的UTC值。

So to summarise if the values in the dump with SET time_zone = "+00:00"; 因此,总结一下转储中的值是否带有SET time_zone = "+00:00"; are all "1 hour behind" the values you see when querying via PHPMyAdmin, this only appears this way because the connection via PHPMyAdmin will have it's timezone one hour ahead of UTC. 都比通过PHPMyAdmin查询时看到的值“落后1小时”,因为只有通过PHPMyAdmin进行的连接将其时区比UTC提前一小时,所以这种显示方式只会如此

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM