使用 PHPMyAdmin 为 MySQL 设置时区

2022-01-05 00:00:00 mysql phpmyadmin

目前,每当用户创建新帐户时,我都会有一个数据类型为 timestamp 的 Creation_date 列.目前,此时间戳比美国东部标准时间早 3 小时(如果在波士顿是下午 5 点,则为晚上 8 点).有没有办法将时区更改为 EST?当前设置为哪个时区?

Currently whenever a user creates a new account, I have a Creation_date column that has datatype timestamp. Currently this timestamp reads 3 hours ahead of EST (if it's 5PM in Boston it reads 8PM). Is there a way to change the timezone to EST? What timezone is it set to currently?

推荐答案

这与 MySQL 的时区有关.

This has to do with MySQL's timezone.

您可以通过以下方式设置每个连接(例如通过 PHPMyAdmin):

You can set it per connection (e.g. via PHPMyAdmin) with the following:

SET time_zone = timezone;

但是,如果 MySQL 重新启动,这将重置.所以最好设置在服务器级别.哪个,我想,你不能.

However, this will reset if MySQL restarts. So it is better set at the server level. Which, I assume, you can't.

我鼓励您从 MySQL 文档中阅读更多内容.

相关文章