How can I change my MySQL database's timezone?

Category: Databases

SeenBean
Asked:
2012-11-24 12:38 am EST

Hits: 426
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

0

JacobIMH
Staff
9,521 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.

How to convert MySQL time

The following command would take the MySQL NOW() 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:

SELECT CONVERT_TZ(NOW(),'-05:00','-06:00');

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

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

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

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

MySQL date and time functions

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?

Related Articles

It looks like there are no related articles.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Need more Help?

Search

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: support@InMotionHosting.com
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!