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?
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.
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).
The following is the syntax to get the current time zone of MySQL. mysql> SELECT @@global. time_zone, @@session.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With