Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the connection timezone in MySQL

Tags:

timezone

mysql

My server is running in MDT

So I used following one to convert EST

SET  time_zone = '-5:00' 

But, how can I switch it to EDT because

While `EST` is only valid in winter, while in summer how to change it to `EDT` 

I just try to used named time zone. But I am getting following error

 #1298 - Unknown or incorrect time zone: 'America/Toronto' 

I don't understand how to solve this problem

How can i switch

UTC -05 TO UTC-04

like image 218
Gowri Avatar asked Apr 01 '11 06:04

Gowri


People also ask

How do I change the timezone in SQL query?

USE time_converter; Step3: Creating table times with 2 columns using the following SQL query as follows. Let us create a table with index and DATETIME as a datatype. CREATE TABLE times (Sno INT, date_time DATETIME);

How do I change the timezone in Mariadb?

You can change the system time zone in several different ways, such as: If you are starting the server with mysqld_safe, then you can set the system time zone with the --timezone option either on the command-line or in the [mysqld_safe] option group in an option file.

Does MySQL use UTC?

Internally, a MySQL timestamp column is stored as UTC. But, when you select a date, MySQL automatically converts the timestamp column to the current session's time zone. MySQL converts TIMESTAMP values from the current time zone to UTC for storage.


2 Answers

For Linux, BSD, and Mac OS X if you need to load the timezone table do this:

$ mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -uroot mysql 
like image 97
Steve Tauber Avatar answered Sep 18 '22 20:09

Steve Tauber


Since you're using Windows, your going to have to import the time zone description tables to your MySQL server.

http://dev.mysql.com/downloads/timezones.html

like image 42
Alpha01 Avatar answered Sep 18 '22 20:09

Alpha01