convert_tz returns null

mohur picture mohur · Jan 22, 2013 · Viewed 44.3k times · Source

I know this sounds stupid, but when I use

SELECT CONVERT_TZ('2004-01-01 12:00:00','UTC','Asia/Jakarta') AS time

it outputs NULL. I'm using MySQL Workbench in Ubuntu 12.04 64 bit, and it works in my other laptop/os (also using MySQL Workbench).

Answer

Barmar picture Barmar · Jan 22, 2013

This will happen if you haven't loaded the time zone table into mysql.

mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql

mysql is the name of the built-in database that holds MySQL-specific configuration data.