Knowledgebase
Webinova Online Customer Support > Webinova Help Desk > Knowledgebase

Search help:


How to change the MySQL timezone

Solution

When you develop your website, you may have to compare a certain date/time with the current date/time on the server.

The timezone on SiteGround’s servers is CST. This is a global setting which cannot be changed.

You can, however, use an easy workaround if you wish to use a different timezone – you can modify the return of the MySQL NOW() function.

Let’s take a look at the most standard query for selecting the current date/time:

SELECT NOW();

If you want to add 2 hours to the result, you can use the following syntax:

SELECT DATE_ADD(NOW(), INTERVAL 2 HOUR);

In a similar way, if you want to subtract 2 hours from the server timezone, you can use this query:

SELECT DATE_SUB(NOW(), INTERVAL 2 HOUR);

Using DATE_SUB and DATE_ADD, you can modify the query result to fit your specific needs.

 
Was this article helpful? yes / no
Article details
Article ID: 203
Category: cPanel MySQL Databases
Date added: 2012-12-07 13:12:15
Views: 15
Rating (Votes): Article rated 3.0/5.0 (2)

 
« Go back

 
Powered by Help Desk Software HESK - brought to you by Help Desk Software SysAid