Mobie
Mobie

Reputation: 1900

setting timezone for MySQL using PHPMyAdmin

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?

Upvotes: 10

Views: 103696

Answers (5)

Alejandro De Castro
Alejandro De Castro

Reputation: 2247

This is a COMPLETE example, for Argentina

SET GLOBAL time_zone = "-03:00";

you just need to change the "-03:00" for your timezone and run that command like a simple query, even in PhpMyAdmin.

Upvotes: 1

Dev M
Dev M

Reputation: 1709

SET GLOBAL time_zone = timezone;

Upvotes: 2

drew010
drew010

Reputation: 69927

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).

Upvotes: 3

Mihai Matei
Mihai Matei

Reputation: 24276

Accordingly with this question

SET SESSION time_zone = '+8:00'

Upvotes: 7

Jason McCreary
Jason McCreary

Reputation: 72961

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.

Upvotes: 11

Related Questions