What is my server's local time zone setting

suggest change

Each server has a default global time_zone setting, configured by the owner of the server machine. You can find out the current time zone setting this way:

SELECT @@time_zone

Unfortunately, that usually yields the value SYSTEM, meaning the MySQL time is governed by the server OS’s time zone setting.

This sequence of queries (yes, it’s a hack) gives you back the offset in minutes between the server’s time zone setting and UTC.

CREATE TEMPORARY TABLE times (dt DATETIME, ts TIMESTAMP);
SET time_zone = 'UTC';
INSERT INTO times VALUES(NOW(), NOW());
SET time_zone = 'SYSTEM';
SELECT dt, ts, TIMESTAMPDIFF(MINUTE, dt, ts)offset FROM times;
DROP TEMPORARY TABLE times;

How does this work? The two columns use different types. The INSERT runs while time_zone is UTC, so both columns store that same NOW() value. DATETIME keeps those components. TIMESTAMP stores UTC and converts to the session time zone on retrieval.

The SELECT runs after time_zone is set back to SYSTEM. TIMESTAMPDIFF(MINUTE, dt, ts) is the offset, in minutes, between that stored UTC reading and local time.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents