Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In MySQL Workbench can I display UTC timestamps in my PC's time?

In MySQL Workbench can I display UTC timestamps in my PC's time?

E.g. I do not want to change the data being saved by the server, I do not wish to change the data that is inserted by the application, or the timezone it's operating in (I'm testing time zone issues in our software).

Can I display the UTC time as my local time, in order to view differences?

Can I do this without changing every query to look at the tables?

like image 967
Ryan Leach Avatar asked Jan 11 '18 08:01

Ryan Leach


People also ask

Does MySQL use UTC?

Internally a MySQL timestamp column is stored as UTC but when selecting a date MySQL will automatically convert it to the current session timezone. When storing a date in a timestamp, MySQL will assume that the date is in the current session timezone and convert it to UTC for storage.

How do I change timezone to UTC in MySQL?

Option 2: Edit the MySQL Configuration File Scroll down to the [mysqld] section, and find the default-time-zone = "+00:00" line. Change the +00:00 value to the GMT value for the time zone you want. Save the file and exit. In the example below we set the MySQL Server time zone to +08:00 (GMT +8).

How do I get MySQL time zone?

The following is the syntax to get the current time zone of MySQL. mysql> SELECT @@global. time_zone, @@session.

What is the data type for time in MySQL?

The DATETIME type is used for values that contain both date and time parts. MySQL retrieves and displays DATETIME values in ' YYYY-MM-DD hh:mm:ss ' format. The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59' . The TIMESTAMP data type is used for values that contain both date and time parts.


1 Answers

To show in your current timezone, use:

SET time_zone = timezone;

For example:

SET time_zone = 'US/Eastern';

It will change the timezone only for your current session.

More information here MySQL Server Time Zone Support

like image 98
Leonardo Avatar answered Oct 20 '22 10:10

Leonardo