Why is the difference of the int type Time field in mysql 8 hours?

Source: Internet
Author: User
Why is the difference between the int type Time field in mysql 8 hours? I checked the time of each record in the client software of the supplier, but I checked it directly in the background using SQLyog, I found that the time field I found was always 8 hours slow. what is the problem?

I used the following statement in the format of 01:37:08. In fact, the correct time for this record is 09:37:08.


SELECT DATE_FORMAT (FROM_UNIXTIME ('table'. 'time'), '% Y-% m-% D % h: % I: % S') AS 'thetime' FROM table


Reply to discussion (solution)

It depends on the time zone settings of your server.

However, the vendor's client software is correct.

If there is no way, add the current time to mysql for 8 hours, and then display the int-type time field in the format of 01:37:08.

The MySQL server has several time zone settings:

· System time zone. When the server starts, it tries to determine the time zone of the host and use it to set the system_time_zone system variable.

· Current time zone of the server. The global system variable time_zone indicates the current time zone used by the server. The initial value is 'system', indicating that the server time zone is the same as the SYSTEM time zone. You can use the -- default-time-zone = timez option to explicitly specify the initial value. If you have the SUPER permission, you can use the following statement to set the global variable value at runtime:

· Mysql> set global time_zone = timezone;
· The time zone of each connection. Each client connection has its own time zone settings, which are given using the session time_zone variable. The initial value is the same as the global variable time_zone, but can be reset using the following statement:

· Mysql> SET time_zone = timezone;
You can use the following method to query the current global variable value and the time zone of each connection:

Mysql> SELECT @ global. time_zone, @ session. time_zone;
The timezone value is a string that indicates the offset of UTC, for example, '+' or '. If you have created and loaded a time zone table in the mysql database, you can also use the named time zone, such as 'Europe/Helsinki ', 'US/Eastern', or 'met '. The value 'system' indicates that the time zone should be the same as the SYSTEM time zone. The time zone name is case insensitive.

SELECT @ global. time_zone, @ session. time_zone

Both fields show system

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.