How to change timezone for MySQL on a cPanel serverServer Management
For many of the websites there will be different time elements used for displaying time. It will use the server time this, but in some cases we need to have different time for the website and it is not possible to change the server time.
So in that case we can change the timezone for MySQL to keep the website updated with the required timezone. For that first you need to know the function that will display the timezone for MySQL, it is the “MySQL NOW()” function that display the timezone. To check the current time using MySQL, you need to enter into the command line and call the “MySQL NOW()” function.
root@srv24x7 [~]# mysql -e "SELECT NOW()"; +---------------------+ | NOW() | +---------------------+ | 2015-04-07 01:28:25 | +---------------------+ root@srv24x7 [~]# date Mon Apr 23 01:28:35 CDT 2015
mysql -e "SELECT NOW()";
will show the date and time set to mysql function.
So by modifying this function, you can set different time to your website. For that see the following examples to add various modifications to the function.
For increment 4 hours to the value of “SELECT NOW()” function you can use syntax as follows,
SELECT DATE_ADD(NOW(), INTERVAL 4 HOUR);
And for decrease 4 hours from the current value, you need to use the syntax as follows,
SELECT DATE_SUB(NOW(), INTERVAL 4 HOUR);
Need assistance with any technical problems ?
Register your support account from here and submit a ticket.