MySQL CONVERT_TZ Function Returning Null
Problem:
When executing the following query:
SELECT CONVERT_TZ('2004-01-01 12:00:00','UTC','Asia/Jakarta') AS time
in MySQL Workbench on Ubuntu 12.04, NULL is returned.
Solution:
This issue occurs when the time zone table has not been loaded into MySQL. To resolve it, execute the following command:
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql
where "mysql" is the name of the built-in database used for MySQL configuration data. This command loads the time zone information into the MySQL database, allowing the CONVERT_TZ function to work properly.
The above is the detailed content of Why is MySQL's CONVERT_TZ Function Returning NULL and How Can I Fix It?. For more information, please follow other related articles on the PHP Chinese website!