InMotion Hosting Support Center

Are timezones supported in MySqL ?

Category: Server Usage

2012-04-22 8:06 pm EST

Hits: 960
I am trying to use the CONVERT_TZ functiuon

SELECT CONVERT_TZ( '2005-01-27 13:30:00', 'UTC', 'UTC' )

(just an example)
But always getting a NULL answer...

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

You must login before you can submit an answer.



Tim S
13,821 Points
2012-04-23 9:57 am EST
Hi limeyx,

Thanks for posting your question. I'm more than happy to assist you today. While timezones are available in MySQL you do not have access to the server's timezones table. Therefore, any SQL statement you write with the timeszones in it will return a NULL value.

I've created a workaround for this:

<p class="code_block">SELECT CONVERT_TZ( '2005-01-27 13:30:00', '+00:00','+01:00' ) </p>

This uses the actual offsets to convert the value. You'll have to manually count the offset in time and replace the '+01:00' in the code snippet. The first set '+00:00' says it's a default or base time. If you run the command from above, it will offset the time by adding one hour to it.

I hope this helps! If you need further assistance please feel free to contact us.


Tim S

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

Like this Question?

Support Center Login

Our Login page has moved, Click the button below to be taken to the login page.

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!