MySQL: Convert Column From One Timezone to Another

It’s a pretty common thing to find an app that doesn’t specify to MySQL the timezone that should be used when storing dates and times. Once you’ve fixed that, you may still have a bunch of dates and times that need to be converted.

UPDATE `my_table` 
SET `some_column` = CONVERT_TZ(`some_column`,'-04:00','-07:00');

In this example I’m showing a timezone conversion for a column where the old timezone was US Eastern time, and the new timezone will be US Pacific time.

Posted February 14th, 2015 in

Leave a comment