Are timezones supported in MySqL ?

Category: Server Usage

limeyx
Asked:
2012-04-22 8:06 pm EST

Hits: 936
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.

OTHER ANSWERS

0

Tim S.
Staff
9,967 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:

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



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.

Thanks!

Tim S

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!