Many times different time zones can create some confusion among the developers. Therefore, there is a need to check the current time zone of MySQL in a lot of cases. In this article, we will learn how to check the current time zone of MySQL.
The time zone of MySQL can be retrieved using the time zone variables. Let us see how to use them for the purpose.
Observe the below query to get the current time zone.
The output in image_1 shows that the current time zone of MySQL is IST.
- Reset AUTO INCREMENT in MySQL
- LIMIT with OFFSET in MYSQL
- MySQL: get column names and datatypes of a table
- Create Temporary Table in MySQL
The @@GLOBAL.time_zone gets the global time zone value. Observe the below query.
The output in image_2 shows that MySQL takes the global time zone value from what is set in the working system.
The @@SESSION.time_zone gets the session time zone value. Observe the below query.
The output in image_3 shows that MySQL takes the session time zone value from what is set in the working system.
MySQL function now() will return the date and time values as per the timezone set for MySQL. Observe the below query.
- Find all tables with specific column names in MySQL
- MySQL add primary key multiple columns
- Mysql update set multiple columns
- Mysql update column with value from another table
- Select all columns except one of a MySQL table
- MySQL ADD COLUMN IF NOT EXISTS
- MYSQL: change column order
- MySQL: change column type to VARCHAR without losing data
- MySQL get column names
We hope this article helped you to get the current time zone of MySQL. Good Luck!!!