How do I get the current time zone of MySQL?


The following is the syntax to get the current time zone of MySQL.

mysql> SELECT @@global.time_zone, @@session.time_zone;

The following is the output.

+--------------------+---------------------+
| @@global.time_zone | @@session.time_zone |
+--------------------+---------------------+
| SYSTEM             | SYSTEM              |
+--------------------+---------------------+
1 row in set (0.00 sec)

The above just returns “SYSTEM” because MySQL is set for system time zones.

Alternately, we can get the current time zone with the help of now() function. Let us first create a new table for our example.

mysql> create table CurrentTimeZone
   -> (
   -> currenttimeZone datetime
   -> )ENGINE=MYISAM;
Query OK, 0 rows affected (0.19 sec)

Inserting records into table.

mysql> INSERT INTO CurrentTimeZone values(now());
Query OK, 1 row affected (0.10 sec)

Displaying current time zone.

mysql> select *from CurrentTimeZone;

The following is the output.

+---------------------+
| currenttimeZone     |
+---------------------+
| 2018-10-29 17:20:12 |
+---------------------+
1 row in set (0.00 sec)

Updated on: 30-Jul-2019

5K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements