To change the timezone within a shared hosting, where you cant change the MySQL’s timezone, you need to execute a query which needs to be run after every MySQL you connect for database.
Change Timezone Shared Hosting
If you have a shared hosting, or due to any other reason, where you cannot change the MySQL’s timezone, here is what you need to do to fulfill your need of changing the timezone.
In the connection file, or whichever file where you connect to MySQL database, simply run the following query after you connect to the database.
SET time_zone = '-6:00';
In PHP, you could write the code below:
mysql_query("SET time_zone = '-6:00'");
By executing the above query, your connection’s timezone will be decreased to -6 hours as per the actual timezone is set over there in the database.
Check Current Timezone – MySQL
To check MySQL’s current timezone, write the following query, which will return you the difference of GMT and the current timezone of MySQL:
SELECT TIMEDIFF(NOW(), CONVERT_TZ( NOW(),@@session.time_zone,'+00:00' ) );
By checking the timezone of MySQL, you can easily manage the difference of GMT and can set your current timezone in PHP connection, which you want.