setting timezone for MySQL using PHPMyAdmin

2019-01-24 11:44发布

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?

3条回答
倾城 Initia
2楼-- · 2019-01-24 12:10

Accordingly with this question

SET SESSION time_zone = '+8:00'
查看更多
霸刀☆藐视天下
3楼-- · 2019-01-24 12:14

TIMESTAMP values are converted to UTC when inserted into the DB and converted back to the current timezone set in MySQL on retrieval. The other answers show how to set the timezone in MySQL which will determine what value comes out of the database.

Another option is to use a DATETIME column, store ALL of your dates in UTC, and convert them to the desired timezone in your application (PHP or wherever you get the values from).

查看更多
Deceive 欺骗
4楼-- · 2019-01-24 12:18

This has to do with MySQL's timezone.

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

SET time_zone = timezone;

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

I encourage you to read more from the MySQL Docs.

查看更多
登录 后发表回答