
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
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)
- Related Articles
- How do I get the current date and time in JavaScript?
- How to get current time zone in android using clock API class?
- How do I get the current AUTO_INCREMENT value for a table in MySQL?
- Get the default Time Zone in Java
- How do I get the current date in JavaScript?
- Java Program to display Current Time in another Time Zone
- Get all the IDs of the Time Zone in Java
- How can I get the current time and date in Kotlin?
- How to return the time-zone offset in minutes for the current locale?
- mysql_tzinfo_to_sql - Load the Time Zone Tables in MySQL
- How do I display the current date and time in an iOS application?
- How do I display the current date and time in an Android application?
- How do I get the creation date of a MySQL table?
- How do I get current URL in Selenium Webdriver 2 Python?
- How do I get time of a Python program's execution?

Advertisements