InMotion Hosting Support Center

How can I change my MySQL database's timezone?

Category: Databases

2012-11-24 12:38 am EST

Hits: 491
I am a bit unsure how to, but I was wondering if the database's timezone was set on the hosting end. Currently, when I submit data with a CURRRENT_TIMESTAMP, the time is 1 hour behind.

Does anyone know how I can change it? Or could possibly point me to the right direction? Thanks.

EDIT: Ah, so I've found the variables tab on my phpMyAdmin page, and there is a date_format that has been preset. Maybe I can somehow edit that to knock the time back to CST?

You must login before you can ask a follow up question.

You must login before you can submit an answer.

Best answer chosen by User


9,968 Points
2012-11-26 11:32 am EST
Hello SeenBean, and thanks for your question.

On a shared server the MySQL time zone is set to the local timezone of that server, in your case EST, and this can't be changed. However you can adjust it on the fly to your needs using a few built in MySQL commands.

<a href="">How to convert MySQL time</a>

The following command would take the MySQL <strong>NOW()</strong> command that gives back the current time stamp, and then you can specify two time zones, the first being EST (-05:00) and the second being CST (-06:00) to get your time zone out of the EST time stamps:

<span class="code_block">SELECT CONVERT_TZ(NOW(),'-05:00','-06:00');</span>

You can also use the <strong>DATE_ADD</strong> and <strong>DATE_SUB</strong> commands to add or subtract hours for the current time stamp on the server as well:

<span class="code_block">SELECT DATE_ADD(NOW(), INTERVAL 1 HOUR);</span><br />
<span class="code_block">SELECT DATE_SUB(NOW(), INTERVAL 1 HOUR);</span>

For further reading you can also check out the MySQL documentation on date and time functions below:

<a href="" rel="nofollow">MySQL date and time functions</a>

Please let us know if you have any other questions at all.

- Jacob

You must login before you can post a comment about this answer.

Like this Question?

Need more Help?


Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail:
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!