Are timezones supported in MySqL ?

Avatar
  • Answered
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...
Avatar
Tim S.
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