- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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 set the timezone of MySQL?
To know the current time, we can use the now() function with SELECT statement. The query is as follows −
mysql> SELECT now();
After executing the above query, we will get the current time. The following is the output −
+---------------------+ | now() | +---------------------+ | 2018-10-06 12:57:25 | +---------------------+ 1 row in set (0.02 sec)
To set the time zone, we can use the command SET. The syntax is as follows −
mysql> SET time_zone = "Some value";
Now I am applying the above query to set the time zone. The query is as follows −
mysql> SET time_zone = "+9:50"; Query OK, 0 rows affected (0.00 sec)
We can set globally as well with the help of SET command −
mysql> set global time_zone="+9:00"; Query OK, 0 rows affected (0.00 sec)
Advertisements