
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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)
Advertisements