
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
Use UTC with MySQL NOW() and CURDATE() Functions
To make MySQL’s NOW() and CURDATE() functions use UTC, you need to write my.cnf file. Write the below instruction in my.cnf −
[mysqld_safe] timezone = UTC
Firstly, reach the directory with the help of the following query −
mysql> select @@datadir;
The following is the output −
+---------------------------------------------+ | @@datadir | +---------------------------------------------+ | C:\ProgramData\MySQL\MySQL Server 8.0\Data\ | +---------------------------------------------+ 1 row in set (0.00 sec)
Now reach the directory for which the link we got as the result of a query. The screenshot of my.cnf file on my Windows system −
Place option( [mysqld_safe] timezone = UTC ) under “mysqld”. You do not have to write on every page load. After placing it once in “my.cnf” file, you do not need to mention it again and again. It will work for every page load.
Call the below query for every page −
mysql> SET time_zone = ' + 0:00'; Query OK, 0 rows affected (0.00 sec)
But it’s not a good practice to call a query every time.
Advertisements