How to change the MySQL timezone

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.

cPanel is easy to work with when you have the right host to support you. If you need a reliable partner to help you manage your website with cPanel, check out our cPanel hosting services!

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to export/import a MySQL database via SSH

In this article we will show you how to export and import a MySQL database via SSH. Managing your...

Error about legacy type authentication (old-style) when connecting remotely to MySQL

This particular error can occur in some MySQL clients. The reason for it is that our servers...

How to change the password of a Mysql user in cPanel?

If you have already created a MySQL user through the cPanel -> Mysql Databases tool you may...

How to reset the password for a MySQL database?

You may need to change the password of your database in order to improve the security of your...

I cannot create views in MySQL

Regular MySQL users do not have privileges to create views in MySQL. If you try to execute CREATE...

Powered by WHMCompleteSolution